All Products
Search
Document Center

AnalyticDB:DescribeSQLPlan

Last Updated:Aug 28, 2026

Queries the plan information about an SQL statement, such as a query statement or an extract-transform-load (ETL) task statement.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

adb:DescribeSQLPlan

get

DBCluster

acs:adb:{#regionId}:{#accountId}:dbcluster/{#DBClusterId}

None None

Request parameters

Parameter

Type

Required

Description

Example

DBClusterId

string

Yes

The cluster ID.

Note

You can call the DescribeDBClusters operation to query the information about all AnalyticDB for MySQL clusters within a region, including cluster IDs.

am-****************

ProcessId

string

Yes

The query ID.

Note

You can call the DescribeProcessList operation to query the IDs of queries that are being executed.

202105271604431720161662490345*******

Response elements

Element

Type

Description

Example

object

The response parameters.

RequestId

string

The request ID.

22D6DEF0-CBC7-4388-A41C-D5FD62******

StageList

array<object>

The execution plan broken down by stage.

object

State

string

The final execution state of the stage. Valid values:

  • FINISHED

  • CANCELED

  • ABORTED

  • FAILED

FINISHED

CPUTimeAvg

integer

The average CPU Time value on each compute node in the stage. Unit: milliseconds.

5984

CPUTimeMax

integer

The maximum CPU Time value on each compute node in the stage. Unit: milliseconds.

5984

OperatorCost

integer

The total CPU time consumed by all operators in the stage, which is equivalent to the total CPU time of the stage. You can use this parameter to identify which parts of the stage consume the most computing resources. Unit: milliseconds.

5984

ScanTimeMax

integer

The maximum time consumed by a scan operator to read data on each storage node in the stage. Unit: milliseconds.

0

InputSizeMax

integer

The maximum input data size on each compute node in the stage. Unit: byte.

173

StageId

integer

The stage ID.

1

ScanSizeMax

integer

The maximum data size scanned by a scan operator on each storage node in the stage. Unit: bytes.

0

CPUTimeMin

integer

The minimum CPU Time value on each compute node in the stage. Unit: milliseconds.

47

ScanTimeMin

integer

The minimum time consumed by a scan operator to read data on each storage node in the stage. Unit: milliseconds.

0

ScanSizeMin

integer

The minimum data size scanned by a scan operator on each storage node in the stage. Unit: bytes.

0

InputSizeMin

integer

The minimum input data size on each compute node in the stage. Unit: bytes.

173

PeakMemory

integer

The peak memory usage during SQL statement execution. Unit: bytes.

74208

ScanTimeAvg

integer

The average time consumed by a scan operator to read data on each storage node in the stage. Unit: milliseconds.

0

ScanSizeAvg

integer

The average data size scanned by a scan operator on each storage node in the stage. Unit: bytes.

0

InputSizeAvg

integer

The average input data size on each compute node in the stage. Unit: bytes.

173

OriginInfo

string

The raw metadata of the SQL statement.

{\"queryId\":\"20210527_160443_10581_hdhzr\",\"session\":{\"queryId\":\"20210527_160443_10581_hdhzr\",\"hasSharedStage\":false,\"parentId\":0}}

Detail

object

The execution details of the SQL statement.

SQL

string

The SQL statement.

INSERT OVERWRITE INTO hdfs_import_external\nSELECT *\nFROM adb_hdfs_import_source

OutputSize

integer

The total output data size of the SQL statement. Unit: bytes.

9

State

string

The final execution state of the SQL statement. Valid values:

  • FINISHED

  • FAILED

FINISHED

OutputRows

integer

The total number of output rows of the SQL statement.

1

User

string

The username that submitted the SQL statement.

test_acc

StartTime

string

The execution start time of the SQL statement, in UNIX timestamp format (milliseconds since January 1, 1970, 00:00:00 UTC).

1622102683243

TotalStage

integer

The total number of stages in the SQL statement.

4

QueuedTime

integer

The time the SQL statement spent in the queue. Unit: milliseconds.

0

TotalTime

integer

The total execution time of the SQL statement. Unit: milliseconds.

2340

TotalTask

integer

The total number of tasks in the SQL statement.

4

Database

string

The database on which the SQL statement was executed.

adb_demo

PeakMemory

integer

The peak memory usage during SQL statement execution. Unit: bytes.

441802

ClientIP

string

The client IP address used to execute the SQL statement.

172.16.***.***

PlanningTime

integer

The time spent generating the execution plan for the SQL statement. Unit: milliseconds.

86

CPUTime

integer

The total CPU time consumed by all operators across multithreaded servers during SQL statement execution. Unit: milliseconds.

6100

Examples

Success response

JSON format

{
  "RequestId": "22D6DEF0-CBC7-4388-A41C-D5FD62******",
  "StageList": [
    {
      "State": "FINISHED",
      "CPUTimeAvg": 5984,
      "CPUTimeMax": 5984,
      "OperatorCost": 5984,
      "ScanTimeMax": 0,
      "InputSizeMax": 173,
      "StageId": 1,
      "ScanSizeMax": 0,
      "CPUTimeMin": 47,
      "ScanTimeMin": 0,
      "ScanSizeMin": 0,
      "InputSizeMin": 173,
      "PeakMemory": 74208,
      "ScanTimeAvg": 0,
      "ScanSizeAvg": 0,
      "InputSizeAvg": 173
    }
  ],
  "OriginInfo": "{\\\"queryId\\\":\\\"20210527_160443_10581_hdhzr\\\",\\\"session\\\":{\\\"queryId\\\":\\\"20210527_160443_10581_hdhzr\\\",\\\"hasSharedStage\\\":false,\\\"parentId\\\":0}}",
  "Detail": {
    "SQL": "INSERT OVERWRITE INTO hdfs_import_external\\nSELECT *\\nFROM adb_hdfs_import_source",
    "OutputSize": 9,
    "State": "FINISHED",
    "OutputRows": 1,
    "User": "test_acc",
    "StartTime": "1622102683243",
    "TotalStage": 4,
    "QueuedTime": 0,
    "TotalTime": 2340,
    "TotalTask": 4,
    "Database": "adb_demo",
    "PeakMemory": 441802,
    "ClientIP": "172.16.***.***",
    "PlanningTime": 86,
    "CPUTime": 6100
  }
}

Error codes

HTTP status code

Error code

Error message

Description

404 InvalidDBCluster.NotFound The DBClusterId provided does not exist in our records. The specified DBClusterId parameter does not exist. Make sure that the DBClusterId value is valid.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.