Updated on 2024-08-05 GMT+08:00

Obtaining Diagnosis Results

Function

This API is used to obtain SQL diagnosis results.

URI

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

Table 1 Path parameters

Parameter

Mandatory

Type

Description

message_id

Yes

String

Diagnosis information ID.

project_id

Yes

String

Project ID.

To obtain this value, see Obtaining a Project ID.

connection_id

Yes

String

Connection ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

X-Language

No

String

Language.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

tune_result

AdviceResult object

Diagnosis result.

Table 4 AdviceResult

Parameter

Type

Description

message_id

String

Diagnosis information ID.

status_code

String

Status code.

error_code

String

Error code.

error_message

String

Error message.

index_advice

Array of IndexAdviceInfo objects

Suggestions on indexes.

tuning_advice

Array of strings

Diagnosis suggestions.

formatted_sql

String

Formatted SQL statement.

original_sql

String

Original SQL statement.

explain

Array of Explain objects

Execution plan.

tb_pos_infos

Array of TbPosInfo objects

Table location information.

feedback_infos

FeedbackInfo object

Feedback information.

Table 5 IndexAdviceInfo

Parameter

Type

Description

schema_name

String

Schema name.

table_name

String

Table name.

index_name

String

Index name.

columns

Array of strings

Column.

unique

Boolean

Unique or not.

track_id

String

Tracking ID.

quality

Object

Quality.

ddl_add_index

String

Index to be added for DDL.

Table 6 Explain

Parameter

Type

Description

id

Integer

Type of the SELECT clause.

select_type

String

Type of the SELECT clause.

table

String

Table JOIN sequence selected by the SQL optimizer.

type

String

Access type of the row in the table,

ordered from the best type to the worst (null>system>const>eq_ref>ref>range>index>all).

possible_keys

String

Index that helps find the required row.

key

String

Index actually used by SQL Optimizer to minimize query costs.

key_len

String

Length (bytes) of the index in the key column.

ref

String

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

rows

Long

Length (bytes) of the index in the key column.

filtered

Double

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

extra

String

Additional information about SQL parsing.

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

Parameter

Type

Description

origin_name

String

Original name.

name

String

Name.

start

Integer

Start.

end

Integer

End.

Table 8 FeedbackInfo

Parameter

Type

Description

id

String

ID.

project_id

String

Project ID.

message_id

String

Unique message ID.

feedback_grade

String

Feedback level.

feedback_content

String

Feedback content.

gmt_created

Long

Creation time.

gmt_modified

Long

Modification time.

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum length: 8

Maximum length: 36

error_msg

String

Error message.

Minimum length: 2

Maximum length: 512

Status code: 500

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum length: 8

Maximum length: 36

error_msg

String

Error message.

Minimum length: 2

Maximum length: 512

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 Code

Status Code

Description

200

Success.

400

Bad request.

500

Internal server error.

Error Code

See Error Codes.