Using SQL statements in ABAP Programming and Database performance

The basic principle for performance is that there should be minimal data transferred between application server and database.

  • For your first question, I would suggest to select only the fields that are required. So, don’t use SELECT * in case you don’t require all the fields. But in specific scenarios, if you have multiple SELECT statements at various parts of your program querying the same table but different columns, it is advisable to use SELECT * as the output is stored in a buffer till your program execute. In that case, when you come to subsequent select, the system uses the buffer memory.
  •     In case you want to get the output in a sorted manner, it is better to use SORT as compared to       ORDER BY.
  •     In case of a nested SELECT statement, be very careful especially if there is a large amount of data expected as output.

Your second query regarding JOIN and FOR ALL ENTRIES IN is irrelevant as both serve a                 different purpose. JOIN is to join two database tables and fetch the data from database whereas       “FOR ALL ENTRIES IN” is used to join a database table with internal memory table. So you can’t  use them as alternatives to each other.