06-17-2014 9:58 AM
To improve the performance, we usually sort a standard table and do binary search when READ TABLE.
Does this only work on key fields that are specified in the table definition.
If I sort the table by a non-key field and do binary search, is it also helpful in performance improvement?
06-17-2014 10:03 AM
Hi Ming,
If you sort a table by a non-key field and use the same field in binary search then it will improve the perfomance.
Regards,
Noufal P
06-17-2014 10:10 AM
Hi Ming,
You may also think about a DDIC table type. There you can specify a primary key and secondary keys. Use this table types as your internal tables. Now you can READ your internal table by different keys.
Regards
Ewald
06-17-2014 10:11 AM
hi ming,
my believe is that binary search by sorting non unique key will make the performance less that sorting with unique key field in internal table..
06-17-2014 10:27 AM
Dear Ming,
If you sort the table by a non-key field and do binary search,
it is also helpful to improve the performance.
but You have to use same keys in read statement which you have used in sorting internal table.(k1, k2)
Eg.
SORT itab BY k1 k2.
then you have to use same key in read statement other wise it returns wrong result.
READ TABLE itab INTO wa_itab
WITH KEY k1 = itab2-k1
k2 = itab2-k2
BINARY SEARCH.
Please find below more points:
1. Don't forget to SORT internal table.
2. Arrange the fields in WITH KEY same with sorting.
3. Put SORT right before READ with BINARY SEARCH or before the loop stament to optimize
Thanks,
Vikas.