This topic describes the terms related to the query process and execution plans of AnalyticDB for MySQL.
Query process
AnalyticDB for MySQL uses SQL statements to help you manage data stored in the system. This section describes
the process of generating an execution plan for an SQL query:
- The client submits SQL statements to a controller node, which is a frontend access node of AnalyticDB for MySQL. For more information about access nodes, see Technical architecture.
- The parser of the controller node parses the SQL statements to generate a syntax tree and then generates a preliminary logical execution plan.
- The optimizer of the controller node evaluates whether the preliminary logical execution plan needs to be optimized and rewritten, generates a final logical execution plan, and then determines whether the plan needs to be split based on network transmission requirements. An execution method is specified in the logical execution plan, including the join type, join order, aggregation method, and data redistribution method.
- An executor node receives the final logical execution plan and converts it into a physical execution plan. The physical execution plan consists of stages and operators that are used to process data based on specific rules.
- The executor node returns the final data processing results to the client or writes the results to AnalyticDB for MySQL tables and external storage systems such as Object Storage Service (OSS).
Terms related to execution plans
The following terms help you better analyze the physical execution plans in AnalyticDB for MySQL.
- stageIn the execution phase, a query in AnalyticDB for MySQL is first split into multiple stages. A stage is a physical part of the execution plan. The data of a stage can come from the underlying storage system or can be transferred over networks. A stage consists of tasks of the same type distributed on different executor nodes. Multiple tasks can process the data in parallel.Note The SQL diagnostics feature of AnalyticDB for MySQL allows you to diagnose results at the stage level. For more information, see Stage-level diagnostic results.
- task
A task is an execution entity of a stage on an executor node. A stage consists of multiple tasks of the same type. Tasks are executed in parallel to process data within a cluster.
- operatorAn operator is the basic data processing unit in AnalyticDB for MySQL. AnalyticDB for MySQL determines whether to process data in parallel or serial mode based on the semantics expressed by the operators or dependencies among the operators.Note The SQL diagnostics feature of AnalyticDB for MySQL allows you to diagnose results at the operator level. For more information, see Operator-level diagnosis results.
The preceding figure shows the execution process of a group aggregation query. A controller
node of AnalyticDB for MySQL distributes the logical execution plan shards of the query to each node that executes
tasks.
- Stage 2 consists of four tasks that scan, filter, and perform partial aggregation on data in parallel.
- Stage 1 consists of two tasks that perform final aggregation in parallel.
- Stage 0 consists of one task that collects the final aggregation results generated from the two tasks of Stage 1.