‎2013 Feb 01 2:41 PM
Hi,
I have 2 hashed tables of same structure. These 2 hashed tables contain different data.
I want to insert lines of one hashed table to the other hashed table.
Usually for reading a record from a hashed table having 1 entry or 100000 entries, it takes same time.
In case of INSERT LINES, will it take the same time for Inserting 1 line or 1000000 lines?
Thanks & Regards,
Adithya M.
‎2013 Feb 01 5:59 PM
Hi Ashish/Akshat/Purnand,
Thanks for your response.
To test this, I created a test program & ran it switching on the Trace in ST12.
When I checked the ABAP Trace in ST12, INSERTING MULTIPLE LINES is having more GrossTime/NetTime % than INSERTING single line.
Also the new lines are Appended instead of Inserting as per the key?
Below is my Test Program.
According to what you said, the last 2 Inserts should have taken same time in ST12. But it didn't happen that way.
Please correct if am checking wrongly.
TYPES: BEGIN OF t_itab,
kunnr TYPE kunnr,
bukrs TYPE bukrs,
zterm TYPE dzterm,
END OF t_itab.
DATA: it_itab1 TYPE HASHED TABLE OF t_itab WITH UNIQUE KEY kunnr,
it_itab2 TYPE HASHED TABLE OF t_itab WITH UNIQUE KEY kunnr,
it_itab3 TYPE HASHED TABLE OF t_itab WITH UNIQUE KEY kunnr.
DATA: wa TYPE t_itab.
wa-kunnr = 1000.
INSERT wa INTO TABLE it_itab1.
wa-kunnr = 1000.
DO 1000000 TIMES.
wa-kunnr = wa-kunnr + 2.
INSERT wa INTO TABLE it_itab2.
ENDDO.
wa-kunnr = 1001.
DO 1000000 TIMES.
wa-kunnr = wa-kunnr + 2.
INSERT wa INTO TABLE it_itab3.
ENDDO.
INSERT LINES OF it_itab1 INTO TABLE it_itab3. "--->Inserting 1 entry
INSERT LINES OF it_itab2 INTO TABLE it_itab3. "--->Inserting multiple entries
‎2013 Feb 01 2:50 PM
Hello,
Hope below link's will help you. https://scn.sap.com/thread/1730834.
http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb361f358411d1829f0000e829fbfe/content.htm
Thanks,
Abhijit
‎2013 Feb 01 2:57 PM
hi,
yes it would take same time.
Number of records does not affect hashed table processing that is the advantage of using hashed table with large number of records.
‎2013 Feb 01 6:06 PM
‎2013 Feb 01 4:57 PM
Hi Adithya,
Yes, I believe it will take the same time to read as well as insert in a hashed table. That's because when you insert an entry into a hashed table, the time critical operation is finding the right place for the entry to be inserted (which is similar to what happens in a read).
‎2013 Feb 01 6:08 PM
‎2013 Feb 01 5:53 PM
Hi Aadhi,
I believe that it will take the same time for Inserting 1 line or 1000000 lines because of its unique key feature and thats its biggest advantage. Its used for processing larger amount of data.
‎2013 Feb 01 6:08 PM
‎2013 Feb 01 5:59 PM
Hi Ashish/Akshat/Purnand,
Thanks for your response.
To test this, I created a test program & ran it switching on the Trace in ST12.
When I checked the ABAP Trace in ST12, INSERTING MULTIPLE LINES is having more GrossTime/NetTime % than INSERTING single line.
Also the new lines are Appended instead of Inserting as per the key?
Below is my Test Program.
According to what you said, the last 2 Inserts should have taken same time in ST12. But it didn't happen that way.
Please correct if am checking wrongly.
TYPES: BEGIN OF t_itab,
kunnr TYPE kunnr,
bukrs TYPE bukrs,
zterm TYPE dzterm,
END OF t_itab.
DATA: it_itab1 TYPE HASHED TABLE OF t_itab WITH UNIQUE KEY kunnr,
it_itab2 TYPE HASHED TABLE OF t_itab WITH UNIQUE KEY kunnr,
it_itab3 TYPE HASHED TABLE OF t_itab WITH UNIQUE KEY kunnr.
DATA: wa TYPE t_itab.
wa-kunnr = 1000.
INSERT wa INTO TABLE it_itab1.
wa-kunnr = 1000.
DO 1000000 TIMES.
wa-kunnr = wa-kunnr + 2.
INSERT wa INTO TABLE it_itab2.
ENDDO.
wa-kunnr = 1001.
DO 1000000 TIMES.
wa-kunnr = wa-kunnr + 2.
INSERT wa INTO TABLE it_itab3.
ENDDO.
INSERT LINES OF it_itab1 INTO TABLE it_itab3. "--->Inserting 1 entry
INSERT LINES OF it_itab2 INTO TABLE it_itab3. "--->Inserting multiple entries
‎2013 Feb 02 2:34 PM
Since you were comparing the behaviour with the read operation and stated the fact that it takes the same amount of time while reading from a hashed table whatever be the number of entries in the table being read, I thought your question was if it would take the same amount of time to insert n records in a hashed table irrespective of the number of entries in the table. And that's what I wrote in my response too. I did not mean to say that it would take the same amount of time to insert a single and multiple records in a hashed table. Of course, the greater the number of records you are inserting, greater will be the time required.
‎2013 Feb 01 7:11 PM
Hi ,
in case of Hashed table it works according to hash algorithm.
Hashed Tables:
Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
using internal tables that are similar to database tables.
What is hashed algorithm?
Hashed algorithm is a one-way mathematical function that encrypts data. The one-way indicates here that with the current computer power and algorithms available the one-way hash cannot be calculated backwards meaning that the hash value cannot be decrypted to reveal the password in clear text again.
Thanks
Sabyasachi
‎2013 Feb 02 7:22 PM
Hi if you got your answer plzz close your thread..
Thanks
Sabyasachi