The following figure shows the typical execution process of an SQL query from its reception by the SQL engine.

The following table describes the steps in the SQL request execution process.
| Step | Description |
|---|---|
| Fast parameterization module | The fast parameterization module converts constants in SQL into parameters, then uses the parameterized SQL text as a key to retrieve the execution plan from the plan cache, so that SQL statements that differ only in parameters can share the same plan. |
| Plan cache | The plan cache module caches the execution plan generated the first time for the SQL in memory. Subsequent executions can repeatedly execute this plan, avoiding the repeated query optimization process. |
| Parser | After receiving the SQL request string sent by the user, the parser splits the string into "words" and parses the entire request based on the preset syntax rules, converting the SQL request string into an in-memory data structure with syntax structure information, called a syntax tree. |
| Resolver | The resolver converts the generated syntax tree into an internal data structure with database semantic information. During this process, the resolver translates tokens in the SQL request into corresponding objects (such as databases, tables, columns, and indexes) based on database metadata, generating a statement tree. |
| Query rewrite | Query rewrite refers to transforming an SQL statement into another form that is easier to optimize. |
| Optimizer | The optimizer is the core of SQL request optimization. It generates the optimal execution plan for SQL requests. During optimization, the optimizer needs to comprehensively consider various factors such as SQL request semantics, object data characteristics, and physical distribution of objects. It addresses core issues including access path selection, join order selection, join algorithm selection, and distributed plan generation, and finally selects the best execution plan for the SQL. |
| Code generator | Converts the execution plan into executable code without making any optimization choices. |