Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding hash table and performance tuning...

Former Member
0 Kudos

Hi,

I have one more question.

1) When do we use hash table in ABAP? what is the advantage of using it?

2) Whenever we want tp performance tune a given report what is the procedure to do it ? Is it just like first run run-time analysis and SQL trace and then see various issues involved like fewer database access and other stuff?

Thanks...

Regards,

Tushar.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

1.

Hashed tables are managed by a hash algorithm. There is no logical index. The entries are not ordered in the memory. The position of a row is calculated by specifying a key using a hash function.

A hashed table's performance in reads is NOT dependent on the number of records. However, it is intended for reads that will return only and only one record. It uses a "side-table" with a hash algorithm to store off the physical location of the record in the actual internal table. It is not NECESSARILY sorted/organized in an meaningful order (like a sorted table is). Please note that changes to a hashed tables records must be managed carefully.

2. First see runtime analysis, try to make 50% of abap time and database time.

Next SQL Trace, check which table is taking more time and try to minimize it by using full key or creating index for the where clause.

Next see logic in the prg, try to avaoid multiple reads on same table and try to minimize unneccessary data

Next try to remove for all entries if it has large amount of data in the for all entries internal table.

Next try to read Header table first than item table.

Next try to put joins

Next try to remove nested select's.

These are some of the tips in performance tunning.

3 REPLIES 3

Former Member
0 Kudos

1.

Hashed tables are managed by a hash algorithm. There is no logical index. The entries are not ordered in the memory. The position of a row is calculated by specifying a key using a hash function.

A hashed table's performance in reads is NOT dependent on the number of records. However, it is intended for reads that will return only and only one record. It uses a "side-table" with a hash algorithm to store off the physical location of the record in the actual internal table. It is not NECESSARILY sorted/organized in an meaningful order (like a sorted table is). Please note that changes to a hashed tables records must be managed carefully.

2. First see runtime analysis, try to make 50% of abap time and database time.

Next SQL Trace, check which table is taking more time and try to minimize it by using full key or creating index for the where clause.

Next see logic in the prg, try to avaoid multiple reads on same table and try to minimize unneccessary data

Next try to remove for all entries if it has large amount of data in the for all entries internal table.

Next try to read Header table first than item table.

Next try to put joins

Next try to remove nested select's.

These are some of the tips in performance tunning.

0 Kudos

How do we seelect hash function if we are using hash table in ABAP? Can you give small example.

Points will be surely awarded..

Thanks..

0 Kudos

DATA: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE I,

END OF LINE.

DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1.

DO 4 TIMES.

LINE-COL1 = SY-INDEX.

LINE-COL2 = SY-INDEX ** 2.

INSERT LINE INTO TABLE ITAB.

ENDDO.

LINE-COL1 = 2. LINE-COL2 = 3.

READ TABLE ITAB FROM LINE INTO LINE COMPARING COL2.

WRITE: 'SY-SUBRC =', SY-SUBRC.

SKIP.

WRITE: / LINE-COL1, LINE-COL2.

for more info see below link

http://help.sap.com/saphelp_erp2004/helpdata/en/fc/eb362c358411d1829f0000e829fbfe/frameset.htm

sure you will understand how to use hast tables.