Queries the result of an SQL diagnostic task.

Before you call this operation, make sure that the following requirements are met:

  • The region is set to cn-shanghai if you use an SDK to call Database Autonomy Service (DAS).
  • This operation is applicable to the following database services:
    • ApsaraDB RDS for MySQL
    • ApsaraDB RDS for PostgreSQL
    • ApsaraDB RDS for 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.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesGetRequestDiagnosisResult

The operation that you want to perform. Set the value to GetRequestDiagnosisResult.

InstanceIdStringYesrm-0iwhhl8gx0ld6****

The ID of the database instance.

NodeIdStringNo202****

The ID of the node.

Note This parameter is required if your instance is a PolarDB for MySQL instance, a PolarDB for PostgreSQL(Compatible with Oracle) instance, or an ApsaraDB for MongoDB instance.
MessageIdStringYes61820b594664275c4429****

The unique ID of the diagnostic task. You can call the CreateRequestDiagnosis operation to query the ID.

SqlIdStringNoNone

The ID of the SQL template.

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

The source of the task.

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

Response parameters

ParameterTypeExampleDescription
MessageStringSuccessful

The message that is returned for the request.

Note If the request is successful, Successful is returned. If the request fails, an error message that contains information such as an error code is returned.
RequestIdString800FBAF5-A539-5B97-A09E-C63AB2F7****

The ID of the request.

DataObject

The returned data.

messageIdString61820b594664275c4429****

The unique ID of the diagnostic task.

uuidStringhdm_51fe9bc19ec413f4d530431af87a****

The unique ID of the diagnostic instance.

accountIdString2093****

The ID of the user.

sqlIdString0c95dae3afef77be06572612df9b****

The ID of the SQL template.

engineStringMySQL

The database engine. Valid values:

  • MySQL
  • PostgreSQL
  • SQLServer
  • PolarDBMySQL
  • PolarDBOracle
  • MongoDB
dbSchemaStringdas

The name of the database.

paramString{"":""}

The additional information.

stateInteger2

The state of the diagnostic task. Valid values:

  • 0: The diagnostic task is in progress.
  • 1: A diagnostic error occurred.
  • 2: The diagnostic task is complete.
  • 3: An SQL error occurred.
  • 4: An engine error occurred.
resultString{ "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":[ ] }

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

  • endTime: the end time of the SQL diagnostic task.
  • errorCode: the error code.
    • 0001: The SQL diagnostic task is complete.
    • 0003: The SQL diagnostic 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 diagnostic task.
  • port: the port used to connect to the instance.
  • sqlTag: the SQL tag.
  • startTime: the start time of the SQL diagnostic task.
  • success: indicates whether the request was successful.
  • support: indicates whether the SQL statement can be diagnosed. Valid values:
    • true: The SQL statement can be diagnosed.
    • false: The SQL statement cannot be diagnosed.
  • tuningAdvices : the SQL rewrite suggestions.
gmtCreateString1633071840000

The time when the SQL diagnostic task was created. This value is a UNIX timestamp. Unit: milliseconds.

gmtModifiedString1633071850000

The time when the SQL diagnostic task was modified. This value is a UNIX timestamp. Unit: milliseconds.

CodeString200

The returned HTTP status code.

SuccessStringtrue

Indicates whether the request was successful. Valid values:

  • true: The request was successful.
  • false: The request failed.

Examples

Sample requests

http(s)://das.cn-shanghai.aliyuncs.com/?Action=GetRequestDiagnosisResult
&InstanceId=rm-0iwhhl8gx0ld6****
&NodeId=202****
&MessageId=61820b594664275c4429****
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<GetRequestDiagnosisResultResponse>
    <Message>Successful</Message>
    <RequestId>800FBAF5-A539-5B97-A09E-C63AB2F7****</RequestId>
    <Data>
        <messageId>61820b594664275c4429****</messageId>
        <uuid>hdm_51fe9bc19ec413f4d530431af87a****</uuid>
        <accountId>2093****</accountId>
        <sqlId>0c95dae3afef77be06572612df9b****</sqlId>
        <engine>MySQL</engine>
        <dbSchema>das</dbSchema>
        <param>{"":""}</param>
        <state>2</state>
        <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":[ ] }</result>
        <gmtCreate>1633071840000</gmtCreate>
        <gmtModified>1633071850000</gmtModified>
    </Data>
    <Code>200</Code>
    <Success>true</Success>
</GetRequestDiagnosisResultResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "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 messageDescription
400InvalidParamsThe request parameters are invalid.The error message returned because the specified request parameters are invalid.

For a list of error codes, see Service error codes.