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 specified query
Statistics about the tables, indexes, and columns named in the query
Configurable variables
The query processor has to execute several steps, using several modules, to successfully process a query:
Figure 1-1: : Query processor modules
The parser converts the text of the SQL statement to an internal representation called a query tree.
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.
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.
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.
The code generator converts the query plan generated by the optimizer into a format more suitable for the query execution engine.
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.
The query execution engine executes the ordered steps specified in the query plan provided by the code generator.