Chapter 1: Understanding Query Processing

This chapter provides an overview of the query processor in Adaptive Server® Enterprise.

The query processor is designed to process queries you specify. The processor yields highly efficient query plans that execute using minimal resources, and ensure that results are consistent and correct.

To process a query efficiently, the query processor uses:

The query processor has to execute several steps, using several modules, to successfully process a query:

Figure 1-1: : Query processor modules

Image shows the six steps of the query processor module
  1. The parser converts the text of the SQL statement to an internal representation called a query tree.

  2. This query tree is normalized. This involves determining column and table names, transforming the query tree into conjugate normal form (CNF), and resolving datatypes. At this point, you can determine if the statement may benefit from using the statement cache.

  3. The preprocessor transforms the query tree for some types of SQL statements, such as SQL statements with subqueries and views, to a more efficient query tree.

  4. The optimizer analyzes the possible combinations of operations (join ordering, access and join methods, parallelism) to execute the SQL statement, and selects an efficient one based on the cost estimates of the alternatives.

  5. The code generator converts the query plan generated by the optimizer into a format more suitable for the query execution engine.

  6. The procedural engine executes command statements such as create table, execute procedure, and declare cursor directly. For data manipulation language (DML) statements, such as select, insert, delete, and update, the engine sets up the execution environment for all query plans and calls the query execution engine.

  7. The query execution engine executes the ordered steps specified in the query plan provided by the code generator.