The following table describes the steps in the SQL request execution process.
| Step | Description |
|---|---|
| Quick parameterization module | The quick parameterization module converts constants in SQL statements into parameters. Then, it uses the parameterized SQL statement as the key to retrieve an execution plan from the Plan Cache. This ensures that SQL statements with different parameters can share the same plan. |
| Execution plan cache (Plan Cache) | The first execution plan generated for an SQL statement is cached in memory by the Plan Cache. Subsequent executions can use the same plan, avoiding repeated query optimization. |
| Lexical and syntax parser (Parser) | After receiving an SQL request string, the parser divides the string into individual "words" and parses the entire request based on predefined syntax rules. This process converts the SQL request string into a memory data structure that contains syntax information. The data structure is called a syntax tree (Syntax Tree). |
| Semantic resolver (Resolver) | The resolver converts the syntax tree into an internal data structure that contains database semantics. During this process, the resolver uses database metadata to translate tokens in the SQL request into corresponding objects (such as databases, tables, columns, and indexes). The data structure generated in this way is called a statement tree. |
| Query rewriting (Query Rewrite) | Query rewriting is the process of converting one SQL statement into another to facilitate optimization. |
| Optimizer (Optimizer) | The optimizer is the core component for optimizing SQL requests. It generates the best execution plan for an SQL request. In the optimization process, the optimizer considers the semantics of the SQL request, the characteristics of the data objects, and the physical distribution of the objects. It selects the optimal access path, join order, join algorithm, and distributed execution plan based on these considerations. Finally, it determines the best execution plan for the SQL request. |
| Code generator (Code Generator) | The code generator converts an execution plan into executable code without making any optimization choices. |