DescribeQueryExplain

Updated at:

Queries the execution plan of an SQL statement.

Operation description

  • Currently, you can query the execution plans of SQL statements only for ApsaraDB RDS for MySQL and PolarDB for MySQL instances.

  • Use the latest version of the Alibaba Cloud SDK or the DAS SDK.

  • When you use an SDK to call DAS, you must specify the region as cn-shanghai.

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

hdm:DescribeQueryExplain

get

*All Resource

*

None None

Request syntax

POST  HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The instance ID.

rm-2ze8g2am97624****

NodeId

string

No

The instance ID.

Note

For a PolarDB for MySQL instance, if a instance ID is specified, the execution plan is queried on the specified node. Otherwise, the execution plan is queried on a secondary node. For an ApsaraDB RDS for MySQL High-availability Edition instance, if a instance ID is specified, the execution plan is queried on the specified node. Otherwise, the execution plan is queried on the secondary node.

pi-bp1v203xzzh0a****

Sql

string

Yes

The SQL statement for which to query the execution plan.

select * from test where name = 'mockUser'

DbName

string

No

The database name.

dbtest01

Schema

string

No

The schema information. This is a reserved parameter.

None

Response elements

Element

Type

Description

Example

object

Schema of Response

Code

string

The returned status code. A value of 200 indicates success.

200

Message

string

The message returned for the request.

Note

If the request is successful, Successful is returned. If the request fails, an error message such as an error code is returned.

Successful

RequestId

string

The request ID.

B6D17591-B48B-4D31-9CD6-9B9796B2****

Success

string

Indicates whether the request was successful. Valid values:

  • true: The request was successful.

  • false: The request failed.

true

Data

array<object>

List

object

The returned data.

Id

string

The query ID.

1

SelectType

string

The select type.

SIMPLE

Table

string

The table name.

test

Type

string

The join type.

eq_ref

PossibleKeys

string

The possible indexes.

test_idx

Key

string

The index that is actually used in the execution plan.

PRIMARY

KeyLen

string

The length of the used index.

3

Ref

string

The columns used with the index.

test_column

Rows

string

The number of rows to scan.

1000

Extra

string

The additional information.

None

QueryPlan

string

The reserved field for the PostgreSQL engine.

None

TableList

array

The reserved field for the PostgreSQL engine.

string

The reserved field for the PostgreSQL engine.

None

IndexList

array

The reserved field for the PostgreSQL engine.

string

The reserved field for the PostgreSQL engine.

None

LogicalPlanList

array

The reserved field for the PolarDB-X engine.

string

The reserved field for the PolarDB-X engine.

None

StmtText

string

The reserved field for the SQL Server engine.

None

StmtId

string

The reserved field for the SQL Server engine.

None

NodeId

string

The reserved field for the SQL Server engine.

None

Parent

string

The reserved field for the SQL Server engine.

None

PhysicalOp

string

The reserved field for the SQL Server engine.

None

LogicalOp

string

The reserved field for the SQL Server engine.

None

Argument

string

The reserved field for the SQL Server engine.

None

DefinedValues

string

The reserved field for the SQL Server engine.

None

EstimateRows

string

The reserved field for the SQL Server engine.

None

EstimateIO

string

The reserved field for the SQL Server engine.

None

EstimateCPU

string

The reserved field for the SQL Server engine.

None

AvgRowSize

string

The reserved field for the SQL Server engine.

None

TotalSubtreeCost

string

The reserved field for the SQL Server engine.

None

OutputList

string

The reserved field for the SQL Server engine.

None

Warnings

string

The reserved field for the SQL Server engine.

None

Parallel

string

The reserved field for the SQL Server engine.

None

EstimateExecutions

string

The reserved field for the SQL Server engine.

None

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "Successful",
  "RequestId": "B6D17591-B48B-4D31-9CD6-9B9796B2****",
  "Success": "true",
  "Data": [
    {
      "Id": "1",
      "SelectType": "SIMPLE",
      "Table": "test",
      "Type": "eq_ref",
      "PossibleKeys": "test_idx",
      "Key": "PRIMARY",
      "KeyLen": "3",
      "Ref": "test_column",
      "Rows": "1000",
      "Extra": "无",
      "QueryPlan": "无",
      "TableList": [
        "无"
      ],
      "IndexList": [
        "无"
      ],
      "LogicalPlanList": [
        "无"
      ],
      "StmtText": "无",
      "StmtId": "无",
      "NodeId": "无",
      "Parent": "无",
      "PhysicalOp": "无",
      "LogicalOp": "无",
      "Argument": "无",
      "DefinedValues": "无",
      "EstimateRows": "无",
      "EstimateIO": "无",
      "EstimateCPU": "无",
      "AvgRowSize": "无",
      "TotalSubtreeCost": "无",
      "OutputList": "无",
      "Warnings": "无",
      "Parallel": "无",
      "EstimateExecutions": "无"
    }
  ]
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParams The request parameters are invalid. The request parameters are invalid.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.