This chapter provides an overview of the query processor in Adaptive Server Enterprise.
The query processor processes queries that 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
To successfully process a query, the query processor must execute several steps across several modules, which are shown in Figure 1-1:
Figure 1-1: Query processor modules
The parser converts the text of the SQL statement to an internal representation called a query tree.
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.