Querying the SQL Execution Plan (GET Request)
Function
This API is used to query a SQL execution plan. Currently, only MySQL instances are supported.
URI
GET /v3/{project_id}/instances/{instance_id}/sql/explain
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Explanation: Project ID of a tenant in a region To obtain this value, see Obtaining a Project ID. Constraints: N/A Values: The value can contain 32 characters. Only letters and digits are allowed. Default value: N/A |
instance_id |
Yes |
String |
Explanation: Unique ID of an instance Constraints: Only MySQL instances are supported. Values: The value can contain 32 characters. Only letters and digits are allowed. Default value: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
db_user_id |
Yes |
String |
Explanation: 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 Registering a Database User. Constraints: N/A Values: The value is a UUID containing 36 characters. Only letters, digits, and hyphens (-) are allowed. Default value: N/A |
database |
Yes |
String |
Explanation: Database name Constraints: Only MySQL instances are supported. Values: N/A Default value: N/A |
sql |
Yes |
String |
Explanation: SQL statement Constraints: N/A Values: N/A Default value: N/A |
Request Parameters
None
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
execution_plans |
Array of ExecutionPlan objects |
Explanation: SQL execution plan list. Values: N/A |
error_message |
String |
Explanation: Error message displayed if the SQL execution fails. Values: N/A |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Explanation: Execution plan ID Values: [0, 2^31-1]. The actual value depends on the query result. |
select_type |
String |
Explanation: Type of the SELECT clause Values: N/A |
table |
String |
Explanation: Database table Values: N/A |
partitions |
String |
Explanation: Partition that will match a query record Values: N/A |
type |
String |
Explanation: Access type Values: N/A |
possible_keys |
String |
Explanation: Key (index) that may be used Values: N/A |
key |
String |
Explanation: Key (index) that is used Values: N/A |
key_len |
String |
Explanation: Length of a key to be used Values: N/A |
ref |
String |
Explanation: Column or constant used along with a key to select rows Values: N/A |
rows |
String |
Explanation: Number of rows that MySQL must check during a query Values: N/A |
filtered |
String |
Explanation: Estimated percentage of table rows filtered by table condition Values: N/A |
extra |
String |
Explanation: Other information Values: N/A |
Example Request
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 Response
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 request |
400 |
Bad request |
500 |
Internal server error |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot