GetRequestDiagnosisResult

更新时间:
复制 MD 格式

Call GetRequestDiagnosisResult to retrieve the SQL diagnosis results.

Operation description

This API has the following prerequisites:

  • When you use an SDK to call the DAS service, you must set the region to cn-shanghai.

  • This API does not support querying diagnosis results for automatic SQL optimization.

  • This API supports the following database engines:

    • RDS MySQL

    • RDS PostgreSQL

    • RDS SQL Server

    • PolarDB for MySQL

    • PolarDB for PostgreSQL (Oracle-Compatible)

    • ApsaraDB for MongoDB

Note

RDS PostgreSQL instances require minor kernel version 20220130 or later. To view and upgrade the minor kernel version, see Upgrade the minor kernel version.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

hdm:GetRequestDiagnosisResult

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The instance ID.

rm-0iwhhl8gx0ld6****

NodeId

string

No

The node ID.

Note

This parameter is required for cluster instances such as PolarDB for MySQL, PolarDB for PostgreSQL (Oracle-compatible), and ApsaraDB for MongoDB.

202****

MessageId

string

Yes

The unique diagnosis ID returned by the CreateRequestDiagnosis operation.

Note

If MessageId is the diagnosis ID for automatic SQL optimization, this operation does not return diagnosis results.

61820b594664275c4429****

SqlId

string

No

The SQL template ID.

Note

This parameter is for internal use by the DAS console. You do not need to specify this parameter.

None

Source

string

No

The source of the task.

Note

This parameter is for internal use by the DAS console. You do not need to specify this parameter.

None

Response elements

Element

Type

Description

Example

object

Message

string

The response message.

Note

This parameter returns Successful if the request succeeds. If the request fails, it returns an error message, which may include an error code.

Successful

RequestId

string

The request ID.

800FBAF5-A539-5B97-A09E-C63AB2F7****

Data

object

The returned data.

messageId

string

The unique ID of the diagnosis.

61820b594664275c4429****

uuid

string

The unique identifier of the diagnosed instance.

hdm_51fe9bc19ec413f4d530431af87a****

accountId

string

The user ID.

2093****

sqlId

string

The SQL template ID.

0c95dae3afef77be06572612df9b****

engine

string

The database engine. Valid values:

  • MySQL

  • PostgreSQL

  • SQL Server

  • PolarDB-X

  • PolarDB for Oracle

  • MongoDB

MySQL

dbSchema

string

The database name.

das

param

string

Additional information.

{"":""}

state

integer

The diagnosis status. Valid values:

  • 0: In progress.

  • 1: Diagnosis error.

  • 2: Completed.

  • 3: SQL error.

  • 4: Engine error.

2

result

string

The details of the SQL diagnosis result, returned as a JSON-formatted string.

  • endTime: The end time of the SQL diagnosis.

  • errorCode: The error code.
    • 0001: The diagnosis was successful.

    • 0003: The diagnosis failed.

  • errorMessage: The error message.

  • estimateCost: The estimated cost.
    • cpu: The estimated CPU cost of the query.

    • io: The estimated I/O cost of the query.

    • rows: The estimated number of rows returned by the query.

  • improvement: The performance improvement ratio.

  • indexAdvices: The index suggestions.
    • columns: The index columns.

    • ddlAddIndex: The DDL statement for creating the index.

    • indexName: The index name.

    • schemaName: The schema name.

    • tableName: The table name.

    • unique: Indicates whether the index is a unique index.

  • ip: The instance IP address.

  • messageId: The diagnosis ID.

  • port: The instance port.

  • sqlTag: The SQL tags.
    • PRED_EQUAL: Equality predicate.

    • CNT_QB: Number of query blocks.

    • CNT_TB: Number of tables.

    • JOIN_LEFT: Left join.

    • SEL_SMALL: Small result set selection.

    • AGGR_SEL: Aggregate selection.

    • PRED_LT_EQ / PRED_GT_EQ: Less-than-or-equal-to / greater-than-or-equal-to predicate.

    • PRED_LIKE_PREFIX: LIKE prefix match.

    • ORDER_BY: Contains an ORDER BY clause.

    • LIMIT: Contains a LIMIT clause.

    • GROUP_BY: Contains a GROUP BY clause.

    • JOIN_INNER: Inner join.

    • JOIN_RIGHT: Right join.

    • HAVING: Contains a HAVING clause.

    • UNION: Contains a UNION operation.

  • startTime: The start time of the SQL diagnosis.

  • success: Indicates whether the diagnosis was successful.

  • support: Indicates whether the SQL statement can be diagnosed.
    • true: Supported.

    • false: Not supported.

  • tuningAdvices: The SQL rewrite suggestions.

{ "endTime":1636354256000, "errorCode":"0001", "errorMessage":"TFX成功", "estimateCost":{ "cpu":1.7878745150389268, "io":9.948402604746128, "rows":8.889372575194633 }, "improvement":12933.97, "indexAdvices":[ { "columns":[ "work_no" ], "ddlAddIndex":"ALTER TABLE `test`.`work_order` ADD INDEX `idx_workno` (`work_no`)", "indexName":"idx_workno", "schemaName":"test", "tableName":"work_order", "unique":false } ], "ip":"****.mysql.rds.aliyuncs.com", "messageId":"6188c8cb2f1365b16aee****", "port":3306, "sqlTag":"{\"PRED_EQUAL\":\"Y\",\"CNT_QB\":\"1\",\"CNT_TB\":\"1\"}", "startTime":1636354252000, "success":true, "support":true, "tuningAdvices":[ ] }

gmtCreate

string

The creation time of the SQL diagnosis, provided as a Unix timestamp in milliseconds.

1633071840000

gmtModified

string

The last modification time of the SQL diagnosis, provided as a Unix timestamp in milliseconds.

1633071850000

Code

string

The status code returned.

200

Success

string

Indicates whether the request was successful. Valid values:

  • true: The request succeeded.

  • false: The request failed.

true

Examples

Success response

JSON format

{
  "Message": "Successful",
  "RequestId": "800FBAF5-A539-5B97-A09E-C63AB2F7****",
  "Data": {
    "messageId": "61820b594664275c4429****",
    "uuid": "hdm_51fe9bc19ec413f4d530431af87a****",
    "accountId": "2093****",
    "sqlId": "0c95dae3afef77be06572612df9b****",
    "engine": "MySQL",
    "dbSchema": "das",
    "param": "{\"\":\"\"}",
    "state": 2,
    "result": "{ \"endTime\":1636354256000, \"errorCode\":\"0001\", \"errorMessage\":\"TFX成功\", \"estimateCost\":{ \"cpu\":1.7878745150389268, \"io\":9.948402604746128, \"rows\":8.889372575194633 }, \"improvement\":12933.97, \"indexAdvices\":[ { \"columns\":[ \"work_no\" ], \"ddlAddIndex\":\"ALTER TABLE `test`.`work_order` ADD INDEX `idx_workno` (`work_no`)\", \"indexName\":\"idx_workno\", \"schemaName\":\"test\", \"tableName\":\"work_order\", \"unique\":false } ], \"ip\":\"****.mysql.rds.aliyuncs.com\", \"messageId\":\"6188c8cb2f1365b16aee****\", \"port\":3306, \"sqlTag\":\"{\\\"PRED_EQUAL\\\":\\\"Y\\\",\\\"CNT_QB\\\":\\\"1\\\",\\\"CNT_TB\\\":\\\"1\\\"}\", \"startTime\":1636354252000, \"success\":true, \"support\":true, \"tuningAdvices\":[ ] }",
    "gmtCreate": "1633071840000",
    "gmtModified": "1633071850000"
  },
  "Code": "200",
  "Success": "true"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParams The request parameters are invalid.
403 NoPermission You are not authorized to do this action.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.