Carrying out database-specific performance checks

In this recipe, we will see a few examples of problems of the SELECT statements that the code inspector may highlight. This may help in improving performance of the program at the development stage. The performance checks are available in both the transactions SCI and SCII. We will emphasize on the selection of the database-specific performance checks during variant creation, and some of the typical statements/constructs that may be caught using code inspector.

How to do it...

  1. Within the checks, expand the Performance Checks category.
  2. From the list of checks that appear, select the checks shown in the following screenshot:
    How to do it...

How it works...

The inspection checks the various program and highlights as warning statements that are performance statements. During this, the code inspector checks the syntax of the program and refers to the attributes and technical settings of the tables involved.

  • CHECK or EXIT statements used within a SELECT statement instead of highlighting a WHERE clause.
  • SELECT statements included in a loop such as a DO loop or within a loop at ITAB.
  • Any SELECT statements that use the BYPASSING BUFFER addition.
  • SELECT statements that are without a WHERE clause will be included in the warning. The following is one such example:
    SELECT * FROM ZMYTAB INTO IT_TAB
  • In addition to this, any table that is buffered but is included in a subquery will also result in a warning. This is because the buffering may not be used in this case, since the result of the subquery will be used at the database level in order to determine the selection set of the main SELECT statement.
         SELECT FIELD1 INTO TABLE IT_FIELDS
         FROM ZTAB1
         WHERE FIELD2 EQ 'ABC' AND
                FIELD3 IN ( SELECT FIELD1 FROM ZTAB2
                         WHERE FIELD2 EQ 'Z1' AND FIELD3 EQ'A'.)
  • If the ZTAB2 table is buffered, a warning message will appear in the result.
  • Also, if the coding includes a SELECT statement on any table that is single-record buffered and a SELECT * ENDSELECT statement is used in the program, the corresponding statement will be highlighted in the results.
  • Any query that may cause problems as far as the index selection is concerned will result in a message. In case, the WHERE clause of the query does not correspond to any index in the database for the table in question, a message appears in the inspection results. This hints that there is a possibility that a full sequential scan will be run for the query that could be very time-consuming.
  • Also for indexes, if a particular field is not included in the WHERE clause—for example, if the index in the database comprise of fields A1, B1, and C1, and the WHERE clause of the query includes B1 and C1 but not A1, a warning is generated.

There's more...

Though the Code Inspector aid in writing better code, they have certain limitations. It is possible that a program generates no messages during the inspection, but may be slow when actually executed in QAS or production system.

The code is only analyzed and scanned along with the information pertaining to attributes of the dictionary tables used. The code is not executed (with actual data). The true performance test and analysis must be based on the actual execution tools such as transaction SAT and SQL trace. The checks of code inspector do not replace these tools.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.44.182