Eligibility to skip query processing phases

Almost all statements pass through all query processing phases. However, there are two main exceptions: queries that benefit from plan caching (queries whose plans are already cached by the database server), and bypass queries.

  • Plan caching   For queries contained inside stored procedures and user-defined functions, the database server may cache the execution plans so that they can be reused. For this class of queries, the query execution plan is cached after execution. The next time the query is executed, the plan is retrieved and all the phases up to the execution phase are skipped.

  • Bypass queries   Bypass queries are a subclass of simple queries that have certain characteristics that the database server recognizes as making them eligible for bypassing the optimizer. Bypassing optimization can reduce the time needed to build an execution plan.

    If a query is recognized as a bypass query, a heuristic rather than cost-based optimization is used—that is, the semantic transformation and optimization phases may be skipped and the query execution plan is built directly from the parse tree representation of the query.

 Simple queries
 Forcing optimization, and forcing no optimization
 See also