2020 May 09 7:05 AM
Hi,
I have gone through so many thread to find the exact difference between Standard table vs Hashed table vs Sorted table. But Still I am not clear with exact difference.
1. when to use Standard table vs Hashed table vs Sorted table ?
2020 May 09 7:18 AM
I guess you know the technical differences between them (what is standard, what is sorted, what is hashed), by reading the official ABAP documentation.
The rest is just a matter of cost.
Usually, give more consideration to optimize performance costs rather than memory costs.
Based on that, use the solution with the lowest cost:
2020 May 09 7:18 AM
I guess you know the technical differences between them (what is standard, what is sorted, what is hashed), by reading the official ABAP documentation.
The rest is just a matter of cost.
Usually, give more consideration to optimize performance costs rather than memory costs.
Based on that, use the solution with the lowest cost:
2020 May 09 8:49 AM
Some pratical guidelines:
Standard Table:
Sorted Table:
Hashed Table:
In general, when it comes to reading/inserting/deleting, Hashed Table should outperform Sorted Table (and Standard Table will be so much worse than both regarding reading/deleting), but there can be instances depending on the data, where sorted outperformes hashed. If the number of rows is less then 10'000 or maybe even 100'000 (and there is not a disproportionate number of read access), you might not even note a difference between them as a user waiting for the execution to end (compared to Standard Table you will notice it as a user).
So it all depends on your requirements and, if necessary, you need to carefully plan the implementation and probably make performance tests with large test data using different table types. But if your test data strongly differs from your productive data, your test might be 'useless'.
2020 May 09 8:54 PM
Hashed tables can have better performance only as long as you have the full key for accessing it for all your frequent accesses (or there are secondary keys supporting the rest). Furthermore hashed tables come only with unique keys and do not allow index access (via the primary key). Most usually this is the factor that determines if they can be used or not.
There are also different costs in memory consumption.
Most importantly: standard tables should not be used for huge amount of data with frequent key look-ups. Even if you sort them, only READ TABLE BINARY SEARCH can make use of the order (and LOOP/MODIFY/DELETE cannot without manual coding tricks).
There are some special use cases for standard tables with huge amount of data (the most typical is when you just append the rows, and at the end you loop over the whole table once and that is all) -- the developer needs to know what she or he is doing in the special cases,
2020 May 09 3:28 PM
There is a section in the ABAP Documentation discussing this very topic:
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenselect_table_type_guidl.htm
2020 May 09 3:41 PM
2020 May 09 7:08 PM
From a robust programming perspective (which should always be considered before performance), use HASHED tables for preference, next SORTED tables and STANDARD tables only when you really have to (e.g. CL_SALV_TABLE).
I have never encountered, in 20 years, a performance or memory issue from following this guideline.
2020 May 11 7:28 AM
@gabmarian Thanks, I have gone through above link, and understood the difference clearly.
2020 May 11 7:40 AM
@gabmarian Thanks for providing this link. Perfect Answer. I am closing this thread.