A few (more or less) ABAP-specific hints:
Avoid SELECT * where it is not needed , try to select only those fields that are needed. Reason: each value may be displayed several times during the process (DB Disk → DB Memory → Network → DB Driver → ABAP internal). It's easy to save processor cycles if you still don't need fields. Be very careful if you CHOOSE * a table containing BLOB fields, such as STRING, this can completely kill your database performance, because the contents of the blob are usually stored on different pages.
Do not select SELECT ... ENDSELECT for small to medium result sets , use SELECT ... INTO TABLE instead. Reason: SELECT ... INTO TABLE performs a single selection and does not hold the cursor open, while SELECT ... ENDSELECT usually displays one row for each iteration of the loop.
It was a kind of urban myth - there is no performance penalty when using SELECT as a loop statement. However, this will keep the cursor open during the loop, which can lead to undesirable (but not strictly performance-related) effects.
For large result sets, use the cursor and the internal table. Reason: Same as above and you will avoid too much heap space.
Do not use ORDER BY, use SORT instead. Reason: better scalability of the application server.
Be careful with nested SELECT statements. Although they can be very convenient for small "internal result sets", they represent tremendous performance if a subquery returns a large result set.
Measure, measure, measure Never take anything if you are concerned about performance. Create a representative test data set and run tests for different implementations. Learn how to use ST05 and SAT.
It is impossible to close the second question “once and for all”. First of all, FOR ALL ENTRIES IN combines a database table and an internal (memory) table, while JOIN only works with database tables. Since the database does not know anything about ABAP internal memory, the FOR ALL ENTRIES IN statement will be converted to a set of WHERE statements - try using ST05 to track this. Secondly, you cannot add values from the second table when using FOR ALL ENTRIES IN. Third, keep in mind that FOR ALL ENTRIES IN always implies DISTINCT. There are a few pitfalls - be sure to check out the ABAP online link, all of which are listed there.
If the number of records in the second table is small, both operators should be more or less equal in performance - the database optimizer should simply pre-select all the values from the second table and use the smart join algorithm to filter through the first table. My recommendation: use whatever is good Do not try to set your code to illegibility.
If the number of records in the second table exceeds a certain value, Bad Things [TM] occurs with FOR ALL ENTRIES IN - the contents of the table are divided into several sets, then the query is converted (see above) and restarted for each set.