Queries the execution plan of an SQL statement.
Operation description
Currently, only RDS MySQL and PolarDB MySQL instances support querying SQL execution plans.
When using Alibaba Cloud or DAS software development kit (SDK), we recommend that you use the latest version.
When you call the DAS service using an SDK, you must specify the region as cn-shanghai.
Try it now
Test
RAM authorization
|
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 node ID. Note
For PolarDB MySQL instances, if you provide a node ID, the execution plan will be queried on the specified node. Otherwise, the execution plan will be queried on the read-only node. For RDS MySQL high availability instances, if you provide an instance ID, the execution plan will be queried on the specified node. Otherwise, the execution plan will be queried on the read-only node. |
pi-bp1v203xzzh0a**** |
| Sql |
string |
Yes |
The SQL statement for which you want 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. |
无 |
Response parameters
|
Parameter |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| Code |
string |
The returned status code. A value of 200 indicates that the request was successful. |
200 |
| Message |
string |
The returned message. Note
When the request is successful, this parameter returns Successful. When the request fails, this parameter returns exception information, such as an error code. |
Successful |
| RequestId |
string |
The request ID. |
B6D17591-B48B-4D31-9CD6-9B9796B2**** |
| Success |
string |
Indicates whether the request was successful:
|
true |
| Data |
array |
List |
|
|
object |
The returned data. |
||
| Id |
string |
The query ID. |
1 |
| SelectType |
string |
The query type. |
SIMPLE |
| Table |
string |
The table name. |
test |
| Type |
string |
The join type. |
eq_ref |
| PossibleKeys |
string |
The possible indexes that can be selected. |
test_idx |
| Key |
string |
The index that is actually selected in the execution plan. |
PRIMARY |
| KeyLen |
string |
The length of the index that is actually selected. |
3 |
| Ref |
string |
The columns used by the index. |
test_column |
| Rows |
string |
The number of rows to be scanned. |
1000 |
| Extra |
string |
Additional information. |
无 |
| QueryPlan |
string |
A reserved field for the PG engine. |
无 |
| TableList |
array |
A reserved field for the PG engine. |
|
|
string |
A reserved field for the PG engine. |
无 |
|
| IndexList |
array |
A reserved field for the PG engine. |
|
|
string |
A reserved field for the PG engine. |
无 |
|
| LogicalPlanList |
array |
A reserved field for the PolarDB X engine. |
|
|
string |
A reserved field for the PolarDB X engine. |
无 |
|
| StmtText |
string |
A reserved field for the SQLServer engine. |
无 |
| StmtId |
string |
A reserved field for the SQLServer engine. |
无 |
| NodeId |
string |
A reserved field for the SQLServer engine. |
无 |
| Parent |
string |
A reserved field for the SQLServer engine. |
无 |
| PhysicalOp |
string |
A reserved field for the SQLServer engine. |
无 |
| LogicalOp |
string |
A reserved field for the SQLServer engine. |
无 |
| Argument |
string |
A reserved field for the SQLServer engine. |
无 |
| DefinedValues |
string |
A reserved field for the SQLServer engine. |
无 |
| EstimateRows |
string |
A reserved field for the SQLServer engine. |
无 |
| EstimateIO |
string |
A reserved field for the SQLServer engine. |
无 |
| EstimateCPU |
string |
A reserved field for the SQLServer engine. |
无 |
| AvgRowSize |
string |
A reserved field for the SQLServer engine. |
无 |
| TotalSubtreeCost |
string |
A reserved field for the SQLServer engine. |
无 |
| OutputList |
string |
A reserved field for the SQLServer engine. |
无 |
| Warnings |
string |
A reserved field for the SQLServer engine. |
无 |
| Parallel |
string |
A reserved field for the SQLServer engine. |
无 |
| EstimateExecutions |
string |
A reserved field for the SQLServer engine. |
无 |
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. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.