ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP - Database Accesses → Open SQL → Open SQL - Overview → Open SQL - Performance Notes
Performance Notes for Individual Open SQL Statements
Other versions:
7.31 | 7.40 | 7.54
SELECT
Specification of the resulting set
SINGLE FOR UPDATE
and DISTINCT
are used,
SAP buffering is skipped.
DISTINCT
requires sorting in the database server and should therefore be specified only if you can expect duplicates.
SELECT f ... FROM tab UP TO 1 ROWS
for an arbitrary table field f
.
SELECT
clause, or use a
view.
Specification of the target area
SELECT
-ENDSELECT
loop. Reading
data into an internal table requires more memory space (without the disadvantage) because of a considerably
higher reading speed. If, on the other hand, data is required many times in a program, it should be
read into an internal table. The disadvantage of the increased memory requirement is more than compensated for here through the advantage of a once-off selection.
APPEND
.
... INTO CORRESPONDING FIELDS OF wa
, ...
INTO CORRESPONDING FIELDS OF TABLE itab, and ... APPENDING CORRESPONDING
FIELDS OF TABLE itab require - in comparison to the respective variants without CORRESPONDING
FIELDS - a longer runtime (a runtime, however, that is independent of the size of the solution set). It should therefore be avoided, if possible.
Specification of the WHERE condition
WHERE
clause. In this way, you
prevent data from being transported uselessly across the network and (for example, using CHECK
) having to be sorted again. SELECT
statements, an
index should be created. In the WHERE
clause, the fields of the index must be specified through a logical AND
,
linked with comparisons for equality. All the fields of an index that are behind a field for which a comparison other than EQ
(=
) is specified in the WHERE
clause cannot be used for searching in the index. NOT
in a WHERE
clause cannot be supported by an
index. For example, WHERE fldate >= '20010228'
is better than WHERE NOT fldate < '20010228'
.
IS NULL
.
Therefore, each SELECT
command on a buffered table or a view with fields
from buffered tables, where the command contains ... WHERE f IS [NOT] NULL
,
behaves as if the addition BYPASSING BUFFER
were specified in the FROM
clause.
Grouping Rows
If aggregates and groups are created already in the database system and not later by the application server, this can considerably reduce the data quantity that needs to be transported from the database to the application server.
Sorting Rows
... ORDER BY PRIMARY KEY
, ... ORDER BY f1 f2 ...
is not automatically supported by a (sorted)
index. Without a corresponding index, the resulting set must
be sorted at runtime. On the basis of SAP architecture, this should not take place on the database server,
but on the application server. If it is not appropriate to create a corresponding index, the resulting
set should therefore not be sorted on the database server using ... ORDER BY f1
f2 ..., but on the application server using SORT
. ... ORDER BY f1 f2 ...
should only be used if the sequence of database fields f1 f2 ...
corresponds exactly to the sequence of an
index. ... ORDER BY PRIMARY KEY
, ... ORDER BY f1 f2 ...
skips the
SAP table buffering.
INSERT, UPDATE, MODIFY, DELETE
If several rows of a database table are to be changed, quantity accesses generally give better performance than individual accesses.