Collection Contents Index The role of the optimizer Reading access plans pdf/chap25.pdf

User's Guide
   PART 4. Database Administration and Advanced Use
     CHAPTER 25. Query Optimization       

Steps in optimization


The steps that the Anywhere optimizer follows in generating a suitable access plan are as follows.

  1. The parser converts the query, expressed in SQL, into an internal representation. In doing so, it may rewrite the query, converting it to a syntactically different, but semantically equivalent, form. These conversions make the statement easier to analyze.

  2. Optimization proper commences at OPEN CURSOR. Unlike many other commercial database systems, Anywhere optimizes each statement at the time it executes it.

  3. Perform semantic optimization on the statement. The command is rewritten whenever doing so will lead to better, more efficient, access plans.

  4. Perform join enumeration and group-by optimization for each subquery.

  5. Optimize access order.

Because Anywhere performs just-in time optimization of each statement, the optimizer has access to the value of host variables and stored procedure variables. Hence, it can make better choices because it can perform better selectivity analysis.

Should you execute the same query repeatedly, it is optimized again each time. Because Anywhere saves statistics each time it executes a query, the optimizer also is afforded the opportunity of learning from the experience of executing previous plans and can adjust its choices when appropriate.


Collection Contents Index The role of the optimizer Reading access plans pdf/chap25.pdf