Updated on 2025-11-26 GMT+08:00

Obtaining 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

    Dependency

    das:clouddba:sqlDiagnosis

    Write

    Connection

    Instance

    -

    -

    -

URI

GET /v3/{project_id}/connections/{connection_id}/tuning/{message_id}/show-tuning-result

Table 1 URI parameters

Parameter

Mandatory

Type

Description

message_id

Yes

String

Explanation:

Diagnosis information ID

To obtain the value, see Executing a SQL Diagnosis Task.

Constraints:

N/A

Values:

The value can contain 24 characters. Only letters and digits are allowed.

Default value:

N/A

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

connection_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.

Values:

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

Request Parameters

None

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

tune_result

AdviceResult object

Explanation:

Diagnosis result

Values:

N/A

Table 3 AdviceResult

Parameter

Type

Description

message_id

String

Explanation:

Diagnosis information ID

Values:

N/A

status_code

String

Explanation:

Status code

Values:

N/A

error_code

String

Explanation:

Error code

Values:

N/A

error_message

String

Explanation:

Error message

Values:

N/A

index_advice

Array of IndexAdviceInfo objects

Explanation:

Index suggestion

Values:

N/A

tuning_advice

Array of strings

Explanation:

Diagnosis suggestion

Values:

N/A

formatted_sql

String

Explanation:

Formatted SQL statement

Values:

N/A

original_sql

String

Explanation:

Original SQL statement

Values:

N/A

explain

Array of Explain objects

Explanation:

Execution plan

Values:

N/A

tb_pos_infos

Array of TbPosInfo objects

Explanation:

Table location

Values:

N/A

feedback_infos

FeedbackInfo object

Explanation:

Feedback

Values:

N/A

Table 4 IndexAdviceInfo

Parameter

Type

Description

schema_name

String

Explanation:

Schema name

Values:

N/A

table_name

String

Explanation:

Table name

Values:

N/A

index_name

String

Explanation:

Index name

Values:

N/A

columns

Array of strings

Explanation:

Column

Values:

N/A

unique

Boolean

Explanation:

Whether the value is unique

Values:

N/A

track_id

String

Explanation:

Tracking ID

Values:

N/A

quality

Object

Explanation:

Quality

Values:

N/A

ddl_add_index

String

Explanation:

Index to be added for a DDL

Values:

N/A

Table 5 Explain

Parameter

Type

Description

id

Integer

Explanation:

Type of the SELECT clause

Values:

N/A

select_type

String

Explanation:

Type of the SELECT clause.

Values:

N/A

table

String

Explanation:

Table JOIN sequence selected by the SQL optimizer

Values:

N/A

type

String

Explanation:

Access type of a row in a table

(The access types are sorted in the following order: null > system > const > eq_ref > ref > range > index > all)

Values:

N/A

possible_keys

String

Explanation:

Index that helps efficiently locate rows

Values:

N/A

key

String

Explanation:

Index actually used by SQL Optimizer to minimize query costs

Values:

N/A

key_len

String

Explanation:

Length (bytes) of an index in the key column

Values:

N/A

ref

String

Explanation:

Column or constant for querying data using an index in the key column

Values:

N/A

rows

Long

Explanation:

Length (bytes) of an index in the key column

Values:

N/A

filtered

Double

Explanation:

Percentage of remaining values after data is scanned at the engine layer and filtered based on WHERE

Values:

N/A

extra

String

Explanation:

Additional information about SQL parsing

  • If using index is displayed, the SQL statement uses overwrite indexes and performs well.
  • If using filesort, using temporary, or using where is displayed, the query needs to be optimized.

Values:

N/A

Table 6 TbPosInfo

Parameter

Type

Description

origin_name

String

Explanation:

Original name

Values:

N/A

name

String

Explanation:

Name

Values:

N/A

start

Integer

Explanation:

Start

Values:

N/A

end

Integer

Explanation:

End

Values:

N/A

Table 7 FeedbackInfo

Parameter

Type

Description

id

String

Explanation:

ID

Values:

N/A

project_id

String

Explanation:

Project ID

Values:

N/A

message_id

String

Explanation:

Unique ID of a task message

Values:

N/A

feedback_grade

String

Explanation:

Feedback level

Values:

N/A

feedback_content

String

Explanation:

Feedback content

Values:

N/A

gmt_created

Long

Explanation:

Creation time

Values:

N/A

gmt_modified

Long

Explanation:

Modification time

Values:

N/A

Example Request

None

Example Response

{
	"tune_result": {
		"message_id": "6507f5070cf2476b18473d9b",
		"status_code": "0000",
		"error_message": "Success",
		"formatted_sql": "SELECT *\nFROM test_tb",
		"original_sql": "select * from test_tb",
		"tuning_advice": [
			"The outermost SELECT statement does not have a WHERE condition specified, which could result in more rows being returned than anticipated."
		],
		"explain": [{
			"id": 1,
			"select_type": "SIMPLE",
			"type": "ALL",
			"rows": 100512,
			"filtered": 100
		}],
		"tb_pos_infos": [{
			"origin_name": "test_tb",
			"name": "test_tb",
			"start": 14,
			"end": 21
		}],
		"feedback_infos": {}
	}
}

Status Code

Status Code

Description

200

Successful request

400

Bad request

500

Internal server error

Error Code

See Error Codes.