Pages

Sunday, May 4, 2008

SQL Interface.

SQL Interface.

Select Where VS Select + Check
Always specify your conditions in the Where-clause instead of checking them yourself with
check statements. The database system can then use an index (if possible) and the network
load is considerably less.

Select with Index Support
For all frequently used Select statements, try to use an index. You always use an index if
you specify (a generic part of) the index fields concatenated with logical Ands in the Select statement's Where clause. Note that complex Where clauses are poison for the
statement optimizer in any database system.


Select single vs. Select-Endselect

if there exists at least one row of a database table or view with a certain condition, use
the Select Single statement instead of a Select-Endselect-loop. Select Single requires one
communication with the database system, whereas Select-Endselect needs two.

Select Into table t
It is always faster to use the Into Table version of a Select statement than to use Append
statements.

Select aggregates
If you want to find the maximum, minimum, sum and average value or the count of a database
column, use a select list with aggregate functions instead of computing the aggregates
yourself. Network load is considerably less.

Select Endselect VS Aray Select
If you process your data only once, use a Select-Endselect-loop instead of collecting data
in an internal table with Select Into Table. Internal table handling takes up much more
space.


Select with View
To process a join, use a view instead of nested Select statements. Network load is
considerably less.

Select with join
To read data from several logically connected tables use a join instead of nested Select
statements. Network load is considerably less.

Select with select list
Use a select list or a view instead of Select * , if you are only interested in specific
columns of the table. Network load is considerably less.

Select with buffer support
For all frequently used, read-only tables, try to use SAP buffering. Network load is
considerably less.

No comments: