All Products
Search
Document Center

Database Autonomy Service:GetRequestDiagnosisResult

Last Updated:Dec 23, 2024

Queries the results of an SQL diagnostics task.

Operation description

Before you call this operation, take note of the following items:

  • If you use an SDK to call the API operations of Database Autonomy Service (DAS), you must set the region ID to cn-shanghai.

  • You cannot call this operation to query the diagnostic result of the automatic SQL optimization feature.

  • This operation is applicable to the following database engines:

    • RDS MySQL
    • RDS PostgreSQL
    • RDS SQL Server
    • PolarDB for MySQL
    • PolarDB for PostgreSQL (Compatible with Oracle)
    • ApsaraDB for MongoDB
Note If your instance is an ApsaraDB RDS for PostgreSQL instance, make sure that the minor engine version of your instance is 20220130 or later. For more information about how to check and update the minor engine version of an ApsaraDB RDS for PostgreSQL instance, see Update the minor engine version of an ApsaraDB RDS for PostgreSQL instance.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
hdm:GetRequestDiagnosisResultget
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
InstanceIdstringYes

The instance ID.

rm-0iwhhl8gx0ld6****
NodeIdstringNo

The node ID.

Note You must specify the node ID if your database instance is a PolarDB for MySQL cluster, a PolarDB for PostgreSQL (compatible with Oracle) instance, or an ApsaraDB for MongoDB database.
202****
MessageIdstringYes

The unique ID of the diagnostic task.

Note If you set MessageId to the task ID of the automatic SQL optimization feature, no result is returned.
61820b594664275c4429****
SqlIdstringNo

The SQL template ID.

Note This parameter is required if you call this operation in the DAS console. You do not need to specify this parameter when you call this operation.
None
SourcestringNo

The source of the task.

Note This parameter is required if you call this operation in the DAS console. You do not need to specify this parameter when you call this operation.
None

Response parameters

ParameterTypeDescriptionExample
object
Messagestring

The returned message.

Note If the request was successful, Successful is returned. If the request failed, an error message such as an error code is returned.
Successful
RequestIdstring

The request ID.

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

The returned data.

messageIdstring

The unique ID of the diagnostics task.

61820b594664275c4429****
uuidstring

The unique ID of the diagnostics instance.

hdm_51fe9bc19ec413f4d530431af87a****
accountIdstring

The user ID.

2093****
sqlIdstring

The SQL template ID.

0c95dae3afef77be06572612df9b****
enginestring

The database engine. Valid values:

  • MySQL
  • PostgreSQL
  • SQLServer
  • PolarDBMySQL
  • PolarDBOracle
  • MongoDB
MySQL
dbSchemastring

The name of the database.

das
paramstring

The additional information.

{"":""}
stateinteger

The state of the diagnostics task. Valid values:

  • 0: The diagnostics task is in progress.
  • 1: A diagnostics error occurred.
  • 2: The diagnostics task is complete.
  • 3: An SQL error occurred.
  • 4: An engine error occurred.
2
resultstring

The result of the SQL diagnostics task. The result includes the following information:

  • endTime: the end time of the SQL diagnostics task.

  • errorCode: the error code.

    • 0001: The SQL diagnostics task is complete.
    • 0003: The SQL diagnostics task failed.
  • errorMessage: the error message.

  • estimateCost: the estimated cost.

    • cpu: the estimated CPU utilization of the index.
    • io: the estimated I/O usage of the index.
    • rows: the estimated values of the rows returned for the index.
  • improvement: the performance improvement ratio.

  • indexAdvices: the index recommendations, which include the following information:

    • columns: the index columns.
    • ddlAddIndex: the DDL statement for the index.
    • indexName: the name of the index.
    • schemaName: the name of the database.
    • tableName: the name of the table.
    • unique: indicates whether the index is unique.
  • ip: the IP address of the instance.

  • messageId: the ID of the diagnostics task.

  • port: the port used to connect to the instance.

  • sqlTag: the SQL tag.

  • startTime: the start time of the SQL diagnostics task.

  • success: indicates whether the request was successful.

  • support: indicates whether the SQL statement can be diagnosed. Valid values:

    • true
    • false
  • tuningAdvices : the SQL rewrite suggestions.

{ "endTime":1636354256000, "errorCode":"0001", "errorMessage":"TFX succeeded", "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":[ ] }
gmtCreatestring

The time when the SQL diagnostics task was created. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.

1633071840000
gmtModifiedstring

The time when the SQL diagnostics task was modified. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.

1633071850000
Codestring

The HTTP status code returned.

200
Successstring

Indicates whether the request was successful. Valid values:

  • true
  • false
true

Examples

Sample success responses

JSONformat

{
  "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 succeeded\", \"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 codeError codeError message
400InvalidParamsThe request parameters are invalid.
403NoPermissionYou are not authorized to do this action.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history