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 PlanCache. This ensures that SQL statements with different parameters can share the same plan. |
| Execution plan cache (PlanCache) | The first execution plan generated for an SQL statement is cached in memory by the execution plan cache module. Subsequent executions can use the same plan, avoiding repeated query optimization. |
| Lexical and syntax parser (Parser) | After receiving an SQL request string, the parser module divides the string into individual "words" and parses the entire request according to 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 module converts the syntax tree into an internal data structure that contains database semantics. During this process, the resolver module translates tokens in the SQL request into corresponding database objects (such as databases, tables, columns, and indexes) based on metadata. 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 SQL statement that is easier to optimize. |
| 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 data characteristics of the objects, and the physical distribution of the objects. It selects the optimal access path, join order, join algorithm, and distributed execution plan to ensure the efficiency of the SQL request. |
| Code generator (Code Generator) | The code generator module converts an execution plan into executable code without making any optimization choices. |