This documentation describes how the SAP DB Optimizer processes SQL statements. It provides information about the meaning and possibilities of creating optimal SQL statements for your application.
For general information about the SAP DB database system, see the documentation The SAP DB Database System at the following Internet address: www.sapdb.org ® Documentation.
For information about the syntax of the SQL statements that can be entered in SAP DB, see the Reference Manual: SAP DB 7.4.
Determining the optimal SQL statements for a SAP DB application is an important task. Optimal SQL statements significantly influence the performance of the entire SAP DB application. An SQL statement is optimal if it is written in such a way that it can be processed in as short a time as possible with a minimal storage area requirement.
To process SQL statements optimally, the factors that influence the processing of an SQL statement must be considered. In particular, you should consider the influence of the search conditions on the processing of an SQL statement. There are a series of additional possibilities for runtime improvement for SQL applications.
The SQL statements should be written in such a way that search strategies can be used. The following goals should be achieved in doing so:
· Search only those lines that it is necessary to search
· Restrict results tables and temporary results tables to the smallest possible size
· Postponement of the Search to the FETCH Time
If a large number of changes has been made in a table, you should run the UPDATE STATISTICS statement. This statement updates the details about the tables that are necessary for the work of the Optimizer (such as value distribution, size of tables, and inversions).
If you consider all of these hints, you can write optimal SQL statements.
...
Check your SQL statements for correctness, for example, with the help of the SAP DB tool SQL Studio.
Analyze your SQL statements with regard to the performance that can be achieved through them. To do this, use the appropriate EXPLAIN statements.
Only after you have completed these checks of your SQL statements should you insert them into your application program.