All Products
Search
Document Center

AnalyticDB:Query process and execution plan

Last Updated:Mar 28, 2026

When a query runs slowly or produces unexpected results, understanding how AnalyticDB for MySQL processes and executes SQL helps you interpret execution plans, read SQL diagnostics output, and identify where the query spends its time. AnalyticDB for MySQL breaks every SQL query into a hierarchy of stages, tasks, and operators before executing it across the cluster.

How AnalyticDB for MySQL processes a query

When you submit a SQL query, AnalyticDB for MySQL processes it in five steps:

  1. The client sends the SQL statement to a controller node — the frontend access node of AnalyticDB for MySQL. For details on access nodes, see Technical architecture.

  2. The controller node's parser parses the statement into a syntax tree and produces a preliminary logical execution plan.

  3. The controller node's optimizer evaluates the preliminary plan and rewrites it as needed. The optimizer produces a final logical execution plan that specifies the join type, join order, aggregation method, and data redistribution method. Based on network transmission requirements, the optimizer also determines whether the plan needs to be split.

  4. An executor node receives the final logical execution plan and converts it into a physical execution plan made up of stages and operators that are used to process data based on specific rules.

  5. The executor node returns results to the client, or writes them to AnalyticDB for MySQL tables and external storage systems such as Object Storage Service (OSS).

Execution plan concepts

Stage

A stage is a physical part of the execution plan. At execution time, a query splits into multiple stages. Each stage:

  • Sources data from the underlying storage system or can be transferred over networks.

  • Consists of tasks of the same type distributed across different executor nodes.

  • Runs its tasks in parallel to maximize throughput.

Note The SQL diagnostics feature lets you view diagnostic results at the stage level. For details, see Stage-level diagnostic results.

Task

A task is the execution entity of a stage on a single executor node. Each stage distributes its work across multiple tasks of the same type, and all tasks run in parallel within the cluster.

Operator

An operator is the basic data processing unit in AnalyticDB for MySQL. AnalyticDB for MySQL determines whether to run operators in parallel or serial mode based on the semantics of each operator and the dependencies between operators.

Note The SQL diagnostics feature lets you view diagnostic results at the operator level. For details, see Operator-level diagnosis results.

Example: group aggregation query

The following figure shows how a group aggregation query executes. The controller node splits the logical execution plan into shards and distributes them to executor nodes.

Execute a query plan
StageTasksWhat it does
Stage 24Scans, filters, and performs partial aggregation on data in parallel.
Stage 12Performs final aggregation in parallel on the results from Stage 2.
Stage 01Collects and returns the final aggregation results from Stage 1.

What's next