Help Center/ Data Admin Service/ API Reference/ APIs/ Intelligent O&M/ Obtaining SQL Diagnosis Results
Updated on 2026-08-25 GMT+08:00

Obtaining SQL Diagnosis Results

Function

This API is used to obtain SQL diagnosis results.

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:sqlDiagnosis

    Read

    Instance

    -

    -

    -

URI

POST /v3/{project_id}/connections/{connection_id}/tuning/get-tuning-result

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. Only letters and digits are supported.

Default Value

N/A

connection_id

Yes

String

Definition

Connection ID established between a database account and the database. The database user ID is created using the API in Creating an Instance Connection.

Constraints

N/A

Range

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

Default Value

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

message_id

Yes

String

Definition

SQL diagnosis message ID created in Creating a SQL Diagnosis Task

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

tune_result

Table 4 Object

Definition

Diagnosis result

Range

N/A

Table 4 AdviceResult

Parameter

Type

Description

message_id

String

Definition

Diagnosis information ID

Range

N/A

status_code

String

Definition

Diagnosis task status code

Range

0000

error_code

String

Definition

Error code

Range

  • 0: waiting
  • 1: running
  • 2: failed
  • 3: successful
  • 4: timed out
  • 5: The OBS file has been deleted.

error_message

String

Definition

Error message

Range

N/A

index_advice

Array of Table 5 objects

Definition

Index tuning suggestion list

Range

N/A

tuning_advice

Array of Strings

Definition

Statement tuning suggestion list

Range

N/A

formatted_sql

String

Definition

Formatted SQL statement

Range

N/A

original_sql

String

Definition

Original SQL statement

Range

N/A

explain

Array of Table 6 objects

Definition

Execution plan

Range

N/A

tb_pos_infos

Array of Table 7 objects

Definition

Table information identified in the SQL statement

Range

N/A

feedback_infos

Table 8 object

Definition

Feedback

Range

N/A

Table 5 IndexAdvice

Parameter

Type

Description

schema_name

String

Definition

Schema name

Range

N/A

table_name

String

Definition

Table name

Range

0000

index_name

String

Definition

Index name

Range

N/A

columns

Array of Strings

Definition

Column list

Range

N/A

unique

Boolean

Definition

Unique Key

Range

N/A

track_id

String

Definition

Trace ID

Range

N/A

quality

String

Definition

SQL quality

Range

  • HighQuality
  • NormalQuality
  • LowQuality
  • AbandonQuality

ddl_add_index

String

Definition

Statement for adding an index

Range

N/A

Table 6 Explain

Parameter

Type

Description

id

Integer

Definition

SQL execution ID

Range

N/A

select_type

String

Definition

SELECT type

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

Table name

Range

N/A

type

String

Definition

How MySQL finds rows in a table

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.

rows

Long

Definition

Estimated number of rows to be scanned

Range

N/A

possible_keys

String

Definition

Index that may be selected

Range

N/A

key

String

Definition

Selected index

Range

N/A

filtered

Double

Definition

Percentage of rows that are filtered based on table conditions

Range

N/A

key_len

String

Definition

Number of bytes used in the index

Range

N/A

ref

String

Definition

Column compared with the index

Range

N/A

extra

String

Definition

Extra information

Range

N/A

Table 7 TbPosInfo

Parameter

Type

Description

schema_name

String

Definition

Schema name

Range

N/A

origin_name

String

Definition

Original table name

Range

N/A

name

String

Definition

Table name

Range

N/A

start

Integer

Definition

Start position

Range

N/A

end

Integer

Definition

End position

Range

N/A

Table 8 FeedbackInfo

Parameter

Type

Description

id

Long

Definition

Feedback message ID

Range

N/A

project_id

String

Definition

Project ID

Range

N/A

message_id

String

Definition

Diagnosis information ID

Range

N/A

feedback_grade

String

Definition

Feedback level

Range

N/A

feedback_content

String

Definition

Feedback content

Range

N/A

gmt_created

Long

Definition

Feedback creation time

Range

N/A

gmt_modified

Long

Definition

Feedback modification time

Range

N/A

Example Requests

POST https://das.cn-north-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/connections/179e525e-0e9c-4dcc-9dd7-ee2f36121e23/tuning/get-tuning-result 
 
{ 
 "message_id": "692d5a7a0cf263510807db3b" 
}

Example Responses

Status code: 200

Success.

{
    "tune_result": {
        "message_id": "692d5a7a0cf263510807db3b",
        "status_code": "0000",
        "error_message": "Success",
        "index_advice": [],
        "tuning_advice": [
            "No WHERE condition is specified for the outermost SELECT statement. More rows than expected may be returned."
        ],
        "formatted_sql": "SELECT *\nFROM lbw",
        "original_sql": "SELECT * FROM lbw",
        "explain": [
            {
                "id": 1,
                "select_type": "SIMPLE",
                "table": "lbw",
                "type": "ALL",
                "rows": 1002,
                "filtered": 100.0
            }
        ],
        "tb_pos_infos": [
            {
                "schema_name": "czh_test",
                "origin_name": "lbw",
                "name": "lbw",
                "start": 14,
                "end": 17
            }
        ],
        "feedback_infos": {}
    }
}

Status Codes

Status Code

Description

200

Success.

400

Client error.

500

Server error.

Error Codes

See Error Codes.