2008 Sep 29 2:06 PM
Hello All,
When there is a Sorted Internal Table, is Looping and Fetching a single record is better or to use a READ TABLE with BINARY SEARCH.
Kindly advice.
Best Regards,
Kasi Raaman.R
2008 Sep 29 2:09 PM
For single records -> READ TABLE.
BINARY SEARCH is not necessary for sorted tables (declared as such!), it is already implicit when using addition WITH TABLE KEY.
Thomas
2008 Sep 29 2:09 PM
For single records -> READ TABLE.
BINARY SEARCH is not necessary for sorted tables (declared as such!), it is already implicit when using addition WITH TABLE KEY.
Thomas
2008 Sep 29 2:10 PM
Read table with the Binary Key will be better.
You can try this in SE30. Create two small programs and run the performance test.
Regards,
Naimesh Patel
2008 Sep 29 2:22 PM
If you can you should use sorted tables, because you get automatically the BINARY SEARCH fast and always correct.
Runtime of READ with key (full table key or only first fields) will be similar to LOOP WHERE (same fields).
So if the key is non-unique or you have only a part of the key it is also o.k.
Stanard table with BINARY SEARCH is slightly faster, but we are talking about microseconds, so forgetr the difference.
There you must take about the sorting, either you do it too often and waste a lot of time or to rarely with incorrect results.
=> If possible, then you should always use sorted tables!
Siegfried