Help Center/ Data Admin Service/ API Reference/ APIs (in OBT)/ Intelligent O&M/ Querying the SQL Execution Plan (GET Request)
Updated on 2026-01-20 GMT+08:00

Querying the SQL Execution Plan (GET Request)

Function

This API is used to query a SQL execution plan. Currently, only MySQL instances are supported.

Authorization Information

Each account has permissions to call all APIs, but IAM users must have the required permissions specifically assigned.

  • If you are using role/policy-based authorization, see the required permissions in Permissions Policies and Supported Actions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    das:clouddba:showSqlExecutionPlan

    Read

    Connection

    Instance

    -

    das:clouddba:getSqlExecutionPlan

    -

URI

GET /v3/{project_id}/instances/{instance_id}/sql/explain

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID of a tenant in a region

To obtain this value, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain 32 characters, including only letters and digits.

Default Value

N/A

instance_id

Yes

String

Definition

Unique ID of an instance

Constraints

Only MySQL instances are supported.

Range

The value can contain 32 characters, including only letters and digits.

Default Value

N/A

Table 2 Query parameters

Parameter

Mandatory

Type

Description

db_user_id

Yes

String

Definition

Database user ID, that is, ID of a connection established between the database account and the database. A database user ID is created by calling the API in Creating a Database User.

Constraints

N/A

Range

The value is a UUID containing 36 characters. Only letters, digits, and hyphens (-) are allowed.

Default Value

N/A

database

Yes

String

Definition

Database name

Constraints

Only MySQL instances are supported.

Range

N/A

Default Value

N/A

sql

Yes

String

Definition

SQL statement

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

execution_plans

Array of ExecutionPlan objects

Definition

SQL execution plan list.

Range

N/A

error_message

String

Definition

Error message displayed if the SQL execution fails.

Range

N/A

Table 4 ExecutionPlan

Parameter

Type

Description

id

String

Definition

Execution plan ID

Range

[0, 2^31-1]. The actual value depends on the query result.

select_type

String

Definition

Type of the SELECT clause

Range

  • SIMPLE: simple query
  • PRIMARY: primary query
  • UNION: second or subsequent query in UNION
  • DEPENDENT UNION: related query in UNION
  • UNION RESULT: UNION result set
  • SUBQUERY: subquery
  • DEPENDENT SUBQUERY: related subquery
  • DERIVED: derived table
  • UNCACHEABLE SUBQUERY: subquery that cannot be cached

table

String

Definition

Database table

Range

N/A

partitions

String

Definition

Partition that will match a query record

Range

N/A

type

String

Definition

Access type

Range

  • ALL: full table scan
  • index: full index scan
  • range: range scan
  • ref: non-unique index scan
  • eq_ref: join using a unique index
  • const: constant level
  • system: system level
  • NULL: The table does not need to be accessed.

possible_keys

String

Definition

Key (index) that may be used

Range

N/A

key

String

Definition

Key (index) that is used

Range

N/A

key_len

String

Definition

Length of a key to be used

Range

N/A

ref

String

Definition

Column or constant used along with a key to select rows

Range

N/A

rows

String

Definition

Number of rows that MySQL must check during a query

Range

N/A

filtered

String

Definition

Estimated percentage of table rows filtered by table condition

Range

N/A

extra

String

Definition

Other information

Range

N/A

Example Requests

Querying the SQL execution plan (GET request)

GET https://das.cn-north-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/instances/da304cd5bbb944de828759bc7be3d3fein01/sql/explain?db_user_id=2c250598-1e3c-4d31-bc19-be1d866247e6&database=abc&sql=select 1

Example Responses

Status code: 200

{
  "execution_plans" : [ {
    "id" : "1",
    "select_type" : "SIMPLE",
    "table" : "",
    "partitions" : "",
    "type" : "",
    "possible_keys" : "",
    "key" : "",
    "key_len" : "",
    "ref" : "",
    "rows" : "",
    "filtered" : "",
    "extra" : "No tables used"
  } ]
}

Status Codes

Status Code

Description

200

Successful response

400

Bad request

500

Internal server error

Error Codes

See Error Codes.