Академический Документы
Профессиональный Документы
Культура Документы
The plus
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Some steps that might make FOR ALL ENTRIES more efficient:
If possible, convert the data in the driver table to ranges so a BETWEEN statement is
used instead of and OR statement:
FOR ALL ENTRIES IN i_tab
WHERE mykey >= i_tab-low and
mykey <= i_tab-high.
Nested selects
The plus:
The minus:
The minus
TAB_DEST[] = TAB_SRC[].
TAB-FLAG = 'X'.
MODIFY TAB TRANSPORTING FLAG
WHERE FLAG IS INITIAL.
IF L1 <> L2.
TAB_DIFFERENT = 'X'.
ELSE.
TAB_DIFFERENT = SPACE.
LOOP AT TAB1.
READ TABLE TAB2 INDEX SY-TABIX.
IF TAB1 <> TAB2.
TAB_DIFFERENT = 'X'. EXIT.
ENDIF.
ENDLOOP.
ENDIF.
IF TAB_DIFFERENT = SPACE.
" ...
ENDIF.
IF TAB1[] = TAB2[].
" ...
ENDIF.
WA-DATE = SY-DATUM.
LOOP AT TAB.
MODIFY TAB FROM WA TRANSPORTING DATE.
ENDLOOP.
Using buffered tables improves the performance considerably. Note that in some cases a
stament can not be used with a buffered table, so when using these staments the buffer will be
bypassed. These staments are:
Select DISTINCT
ORDER BY / GROUP BY / HAVING clause
Any WHERE clasuse that contains a subquery or IS NULL expression
JOIN s
A SELECT... FOR UPDATE
If you wnat to explicitly bypass the bufer, use the BYPASS BUFFER addition to the
SELECT clause.
The ORDER BY clause is executed on the database server while the ABAP SORT statement
is executed on the application server. The datbase server will usually be the bottleneck, so
sometimes it is better to move thje sort from the datsbase server to the application server.
If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key
statement) but are sorting by another key, it could be better to use the ABAP SORT stament
to sort the data in an internal table. Note however that for very large result sets it might not be
a feasible solution and you would want to let the datbase server sort it.
As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if
some of the fields are not part of an index. Instead use ABAP SORT + DELETE
ADJACENT DUPLICATES on an internal table, to delete duplciate rows.
DATA: l_data TYPE SORTED TABLE OF ty_data WITH UNIQUE KEY lifnr.