Get Example source ABAP code based on a different SAP table
AB_SQL - Performance Notes The performance of a program is often determined by the efficiency of the database reads it contains. In a client/server environment, each database read places a load on both the database system and the connection between the database system and the AS ABAP. This load must be kept as low as possible if programs are to demonstrate a good level of performance. Generally speaking, the following rules must be followed. The overall performance of a program can depend on the data being processed, any evaluations required, and the database system itself, which means that the application and prioritization of rules can vary from case to case.
Keep the number of hits low> The set of rows selected should be kept as small as possible by using specific conditions to restrict the set to those rows actually needed. Superfluous rows should never be transported from the database system to the AS ABAP and then evaluated there.
Keep the data volume low> The volume of data transported should always be restricted to the columns required. The columns can be specified explicitly, or an ap propriate view can be used. Furthermore, aggregate expressions> can be combined with corresponding groupings SQL expressions> to reduce the volume of data transferred, since here the data is already aggregated before the transport in the database system.
Keep the number of reads low> To keep the number of database reads low, mass operations should always be used instead of single operations. More specifically, AB-SQL statements should not be used within loops. Instead, joins, views, or subqueries can be used when reading multiple DDIC database tables.
Use local buffers> The same data should be not be read more than once. Storing database tables in the local buffer in table buffering> BEGIN_SECTION VERSION 5 OUT and also storing prepared data in Shared Objects> END_SECTION VERSION 5 OUT can produce significant time savings, since it takes much longer for the AS ABAP to read the database system than a locally buffered table. DDIC database tables should always be buffered if they are read frequently and modified rarely. If the same data is to be sorted multiple times in different orders, the data should be sorted in the ABAP program.
Efficient search using indexes> In all cases where secondary indexes > of DDIC database tables improve selection performance, these indexes should be created and used.
ABAP_EXAMPLE_BAD This example uses a SELECT> statement in a SELECT> loop to add values from a different DDIC database table to the work area here. An internal table is filled with the work area, row by row. ABEXA 01205 ABAP_EXAMPLE_END
ABAP_EXAMPLE_GOOD This example uses a join expression to fill an internal table directly. The result is the same as in the previous example. The class CL_DEMO_ABAP_SQL_PERFO>> compares the runtimes of both access methods. The good example is generally far quicker than the bad example. ABEXA 01206 ABAP_EXAMPLE_END