Obtain the execution plan for an SQL statement.
Operation description
-
This operation supports only ApsaraDB RDS for MySQL and PolarDB for MySQL instances.
-
When using the Alibaba Cloud or DAS SDK, use the latest version.
-
When calling the DAS service with the SDK, set the region to 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 ID of the instance. |
rm-2ze8g2am97624**** |
| NodeId |
string |
No |
The ID of the node. Note
For PolarDB for MySQL instances, if you specify a node ID, the system queries the execution plan on that node. Otherwise, it queries the execution plan on a secondary node.For high availability ApsaraDB RDS for MySQL instances, if you specify an instance ID, the system queries the execution plan on that node. Otherwise, it queries the execution plan on a secondary node. |
pi-bp1v203xzzh0a**** |
| Sql |
string |
Yes |
The SQL statement for which you want to get the execution plan. |
select * from test where name = 'mockUser' |
| DbName |
string |
No |
The name of the database. |
dbtest01 |
| Schema |
string |
No |
Schema information. This is a reserved parameter. |
None |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Response schema |
||
| Code |
string |
The status code returned. A value of 200 indicates success. |
200 |
| Message |
string |
The response message. Note
If the request succeeds, this parameter returns Successful. If the request fails, this parameter returns error details such as an error code. |
Successful |
| RequestId |
string |
The ID of the request. |
B6D17591-B48B-4D31-9CD6-9B9796B2**** |
| Success |
string |
Indicates whether the request succeeded:
|
true |
| Data |
array<object> |
List of execution plans. |
|
|
object |
The returned data. |
||
| Id |
string |
The ID of the query. |
1 |
| SelectType |
string |
The type of the query. |
SIMPLE |
| Table |
string |
The name of the table. |
test |
| Type |
string |
The join type. |
eq_ref |
| PossibleKeys |
string |
The indexes that might be used. |
test_idx |
| Key |
string |
The index actually used in the execution plan. |
PRIMARY |
| KeyLen |
string |
The length of the index actually used. |
3 |
| Ref |
string |
The column used by the index. |
test_column |
| Rows |
string |
The number of rows to scan. |
1000 |
| Extra |
string |
Additional information. |
None |
| QueryPlan |
string |
A reserved field for the PostgreSQL engine. |
None |
| TableList |
array |
A reserved field for the PostgreSQL engine. |
|
|
string |
A reserved field for the PostgreSQL engine. |
None |
|
| IndexList |
array |
A reserved field for the PostgreSQL engine. |
|
|
string |
A reserved field for the PostgreSQL engine. |
None |
|
| LogicalPlanList |
array |
A reserved field for the PolarDB X engine. |
|
|
string |
A reserved field for the PolarDB X engine. |
None |
|
| StmtText |
string |
A reserved field for the SQL Server engine. |
None |
| StmtId |
string |
A reserved field for the SQL Server engine. |
None |
| NodeId |
string |
A reserved field for the SQL Server engine. |
None |
| Parent |
string |
A reserved field for the SQL Server engine. |
None |
| PhysicalOp |
string |
A reserved field for the SQL Server engine. |
None |
| LogicalOp |
string |
A reserved field for the SQL Server engine. |
None |
| Argument |
string |
A reserved field for the SQL Server engine. |
None |
| DefinedValues |
string |
A reserved field for the SQL Server engine. |
None |
| EstimateRows |
string |
A reserved field for the SQL Server engine. |
None |
| EstimateIO |
string |
A reserved field for the SQL Server engine. |
None |
| EstimateCPU |
string |
A reserved field for the SQL Server engine. |
None |
| AvgRowSize |
string |
A reserved field for the SQL Server engine. |
None |
| TotalSubtreeCost |
string |
A reserved field for the SQL Server engine. |
None |
| OutputList |
string |
A reserved field for the SQL Server engine. |
None |
| Warnings |
string |
A reserved field for the SQL Server engine. |
None |
| Parallel |
string |
A reserved field for the SQL Server engine. |
None |
| EstimateExecutions |
string |
A 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": "None",
"QueryPlan": "None",
"TableList": [
"None"
],
"IndexList": [
"None"
],
"LogicalPlanList": [
"None"
],
"StmtText": "None",
"StmtId": "None",
"NodeId": "None",
"Parent": "None",
"PhysicalOp": "None",
"LogicalOp": "None",
"Argument": "None",
"DefinedValues": "None",
"EstimateRows": "None",
"EstimateIO": "None",
"EstimateCPU": "None",
"AvgRowSize": "None",
"TotalSubtreeCost": "None",
"OutputList": "None",
"Warnings": "None",
"Parallel": "None",
"EstimateExecutions": "None"
}
]
}
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.