Updated on 2026-01-20 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

    Dependencies

    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

Definition

Diagnosis information ID

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

Constraints

N/A

Range

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

Default Value

N/A

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, including only letters and digits.

Default Value

N/A

connection_id

Yes

String

Definition

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 Creating a Database User.

Range

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

Definition

Diagnosis result

Range

N/A

Table 3 AdviceResult

Parameter

Type

Description

message_id

String

Definition

Diagnosis information ID

Range

N/A

status_code

String

Definition

Status code

Range

N/A

error_code

String

Definition

Error code

Range

N/A

error_message

String

Definition

Error message

Range

N/A

index_advice

Array of IndexAdviceInfo objects

Definition

Index suggestion

Range

N/A

tuning_advice

Array of strings

Definition

Diagnosis suggestion

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 Explain objects

Definition

Execution plan

Range

N/A

tb_pos_infos

Array of TbPosInfo objects

Definition

Table location

Range

N/A

feedback_infos

FeedbackInfo object

Definition

Feedback

Range

N/A

Table 4 IndexAdviceInfo

Parameter

Type

Description

schema_name

String

Definition

Schema name

Range

N/A

table_name

String

Definition

Table name

Range

N/A

index_name

String

Definition

Index name

Range

N/A

columns

Array of strings

Definition

Column

Range

N/A

unique

Boolean

Definition

Whether the value is unique

Range

N/A

track_id

String

Definition

Tracking ID

Range

N/A

quality

Object

Definition

Quality

Range

N/A

ddl_add_index

String

Definition

Index to be added for a DDL

Range

N/A

Table 5 Explain

Parameter

Type

Description

id

Integer

Definition

Type of the SELECT clause

Range

N/A

select_type

String

Definition

Type of the SELECT clause.

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 JOIN sequence selected by the SQL optimizer

Range

N/A

type

String

Definition

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)

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.

possible_keys

String

Definition

Index that helps efficiently locate rows

Range

N/A

key

String

Definition

Index actually used by SQL Optimizer to minimize query costs

Range

N/A

key_len

String

Definition

Length (bytes) of an index in the key column

Range

N/A

ref

String

Definition

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

Range

N/A

rows

Long

Definition

Length (bytes) of an index in the key column

Range

N/A

filtered

Double

Definition

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

Range

N/A

extra

String

Definition

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.

Range

N/A

Table 6 TbPosInfo

Parameter

Type

Description

origin_name

String

Definition

Original name

Range

N/A

name

String

Definition

Name

Range

N/A

start

Integer

Definition

Start

Range

N/A

end

Integer

Definition

End

Range

N/A

Table 7 FeedbackInfo

Parameter

Type

Description

id

String

Definition

ID

Range

N/A

project_id

String

Definition

Project ID

Range

N/A

message_id

String

Definition

Unique ID of a task message

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

Creation time

Range

N/A

gmt_modified

Long

Definition

Modification time

Range

N/A

Example Requests

None

Example Responses

{
	"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 Codes

Status Code

Description

200

Successful response

400

Bad request

500

Internal server error

Error Codes

See Error Codes.