The SQL engine follows a typical process from receiving an SQL request to execution.
The process is illustrated in the following figure.

Note
This execution process applies to DML and SELECT statements. Other statements (such as DCL) do not have optimizer and other steps.
The following table describes the steps in the SQL request execution process.
| Step | Description |
|---|---|
| Fast-parser | Uses lexical analysis to directly parameterize text strings and obtain parameterized text and constant parameters. |
| Parser (lexical/syntactic parsing module) | After receiving the SQL request string from the user, Parser splits the string into individual "tokens" and parses the entire request according to predefined grammar rules. It converts the SQL request string into an in-memory data structure with syntactic information, called a syntax tree. |
| Plan Cache (plan cache module) | Caches the execution plan generated for the SQL the first time in memory. Subsequent executions can reuse this plan, avoiding repeated query optimization. |
| Resolver (semantic parsing module) | Resolver converts the generated syntax tree into an internal data structure with database semantic information. During this process, Resolver translates tokens in the SQL request into corresponding objects (such as databases, tables, columns, and indexes) based on database metadata to generate a statement tree. |
| Transformer (logical rewrite module) | Analyzes the semantics of the user SQL and rewrites it into an equivalent form based on internal rules or cost models for further optimization by the optimizer. Transformer performs equivalent transformations on the original statement tree; the result is still a statement tree. |
| Optimizer | The core of SQL request optimization. It generates the optimal execution plan for SQL requests. During optimization, the optimizer considers SQL semantics, object data characteristics, physical distribution, and other factors to address access path selection, join order selection, join algorithm selection, distributed plan generation, and other core issues, and finally selects the best execution plan for the SQL. |
| Code Generator | Converts the execution plan into executable code without making any optimization choices. |
| Executor | Starts the SQL execution process.
|