We just had a discussion with some colleagues about the Title. We currently don't have the opportunity to test it on our Systems, cause the Dev-Systems are being patched right now.
Can someone answer the Question, which of the following is faster, even though READ TABLE is much more used:
SELECT SINGLE col
FROM @itab
INTO @DATA(dat).
READ TABLE itab ASSIGNING FIELD-SYMBOL(<dat>) TRANSPORTING col.
SELECT SINGLE *
FROM @itab
INTO @DATA(dat).
READ TABLE itab ASSIGNING FIELD-SYMBOL(<dat>).
I know SELECT is way more flexible, cause you can use pretty much the entire OpenSQL-Syntax, but just for these Examples, which will be faster? Does it change if we add a Condition (WHERE or WITH KEY/WITH TABLE KEY)? Does it change with the Size of itab?
For a theoretical question here's a theoretical answer:
The documentation states:
So as long as your
SELECT FROM @itabstatement does not contain anything that requires the query to be pushed down to the database, it will perform some algorithm on an internal table. LikewiseREAD TABLEwill perform some algorithm on an internal table. So conceptually - as long as equivalent operations are performed by both statements - there should be no difference between the two.In reality however I would assume that
READ TABLEperforms some short circuits thatSELECTdoes not and vice versa, so whether one is faster or not can likely differ on a case by case basis.That said, I would personally prefer
SELECToverREAD TABLEas it is well known and analogous to selection from database tables, also it is way more flexible and powerful.