Having the following statements:
SELECT * FROM tadir ORDER BY PRIMARY KEY INTO TABLE @DATA(lt_tadir).
DATA lt_tadir TYPE SORTED TABLE OF tadir WITH UNIQUE KEY pgmid object obj_name.`
SELECT * FROM tadir INTO TABLE @lt_tadir.
Why is the first one around 4 times slower (verified on multiple systems? Relevant statements from the documentation:
For performance reasons, a sort should only take place in the database if supported by an index. This guaranteed only when ORDER BY PRIMARY KEY is specified
If a sorted resulting set is assigned to a sorted internal table, the internal table is sorted again according to the sorting instructions.
First I thought maybe column storage is an issue, but I tried another column storage table where both statements are around similar (even though the second one seems to be a bit faster each time). Same for the row storage I tested.
Also I somehow would have expected that the sort in ABAP (second Docu snipped) would have an performance impact. But it outperforms the primary key index select.
Tables aren't fully buffered, and even if that was the case, ORDER BY PRIMARY KEY does use the buffer.
Any ideas?
