A query plan is a physical execution plan, which includes the following elements: stage, task, and operator.
- When AnalyticDB for MySQL executes a query, the query is first split into multiple stages. A stage is a physical part of the execution plan. The data of a stage can come from underlying data sources or data redistribution between upstream stages. Tasks distributed on multiple executor nodes are executed in parallel to process the data of a stage. For more information about how to generate an execution plan, see Execution plan generation.
- 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.
- An operator is the basic processing unit in AnalyticDB for MySQL. Multiple operators form upstream and downstream relationships within a task and process data in parallel or serial mode. Whether operators are processed in parallel or serial mode depends on the semantics expressed by multiple operators or the dependencies between operators.
As shown in the following figure, a controller node sends plan shards to an executor node. Stage 2 is executed by tasks on four executor nodes, Stage 1 by tasks on two executor nodes, and Stage 0 by a task on one executor node. The execution result is returned by the task where Stage 0 is deployed to the controller node, and then to the client.