Queries optimization suggestions that are generated by the SQL diagnostics feature of Database Autonomy Service (DAS).

The SQL diagnostics feature provides optimization suggestions for instances based on diagnostic results. You can use the optimization suggestions to optimize instance indexes. For more information, see Automatic SQL optimization.

Note This operation can be used to query only the optimization suggestions that are automatically generated by the SQL diagnostics feature.

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

  • This operation can be used only for ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.
  • If you use an Alibaba Cloud SDK, make sure that the aliyun-sdk-core version is V4.3.3 or later. We recommend that you use the latest version.
  • The version of DAS SDK must be 1.0.8 or later.
  • If you use an SDK to call the DAS service, you must set the region to cn-shanghai.

Request parameters

Parameter Type Required Example Description
Action String Yes GetSqlOptimizeAdvice

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

ConsoleContext String No None

A reserved parameter.

Engine String No MySQL

The database engine. Valid values:

  • MySQL: ApsaraDB RDS for MySQL
  • PolarDBMySQL: PolarDB for MySQL
InstanceIds String No rm-2ze1jdv45i7l6****

The ID of the instance.

Note The instance must be an ApsaraDB RDS for MySQL instance or a PolarDB for MySQL cluster.
StartDt String No 20210916

The start of the date range during which SQL suggestions are generated. Specify the date in the yyyyMMdd format. The time must be in UTC.

Note
  • The default value of this parameter is the day before the current day.
  • The value must be earlier than the current day.
EndDt String No 20210917

The end of the date range during which SQL suggestions are generated. Specify the date in the yyyyMMdd format. The time must be in UTC.

Note
  • The default value of this parameter is the day before the current day.
  • The value must be earlier than the current day. The interval between the start date and end data cannot be longer than 30 days.

Response parameters

Parameter Type Example Description
Code String 200

The returned HTTP status code.

Message String Successful

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.
Data Object

The detailed information, including the error codes and the number of error messages.

Status String FINISH

The status of the task. Valid values:

  • INIT: The task is being initialized.
  • RUNNING: The task is running.
  • FINISH: The task is completed.
  • FAILED: The task failed.
StatusCode String SUCCESS

The status code of the task. Valid values:

  • NO_DATA: No data is returned.
  • INTERNAL_ERROR: An internal error occurred.
  • SUCCESS: The task is successful.
DownloadUrl String https://das-sql-optimize.oss-cn-shanghai.aliyuncs.com/adb/oss_sql_optimize_advice/1083*******

The URL used to download the file.

CreateTime String 1632303861000

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

ExpireTime String 1632563061000

The time when the file expires. This value is a UNIX timestamp. Unit: milliseconds.

Note The file expires three days after the task is created.
TaskId String 2021091710461519216****

The ID of the task.

RequestId String B6D17591-B48B-4D31-9CD6-9B9796B2****

The ID of the request.

Success String true

Indicates whether the request is successful. Valid values:

  • true
  • false

Examples

Sample requests

http(s)://das.cn-shanghai.aliyuncs.com/?Action=GetSqlOptimizeAdvice
&Engine=MySQL
&InstanceIds=rm-2ze1jdv45i7l6****
&StartDt=20210916
&EndDt=20210917
&Common request parameters

Sample success responses

XML format

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

<GetSqlOptimizeAdviceResponse>
    <Code>200</Code>
    <Message>Successful</Message>
    <Data>
        <Status>FINISH</Status>
        <StatusCode>SUCCESS</StatusCode>
        <DownloadUrl>https://das-sql-optimize.oss-cn-shanghai.aliyuncs.com/adb/oss_sql_optimize_advice/1083*******</DownloadUrl>
        <CreateTime>1632303861000</CreateTime>
        <ExpireTime>1632563061000</ExpireTime>
        <TaskId>2021091710461519216****</TaskId>
    </Data>
    <RequestId>B6D17591-B48B-4D31-9CD6-9B9796B2****</RequestId>
    <Success>true</Success>
</GetSqlOptimizeAdviceResponse>

JSON format

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

{
  "Code" : "200",
  "Message" : "Successful",
  "Data" : {
    "Status" : "FINISH",
    "StatusCode" : "SUCCESS",
    "DownloadUrl" : "https://das-sql-optimize.oss-cn-shanghai.aliyuncs.com/adb/oss_sql_optimize_advice/1083*******",
    "CreateTime" : "1632303861000",
    "ExpireTime" : "1632563061000",
    "TaskId" : "2021091710461519216****"
  },
  "RequestId" : "B6D17591-B48B-4D31-9CD6-9B9796B2****",
  "Success" : "true"
}

Error codes

HTTP status code Error code Error message Description
400 InvalidParams The request parameters are invalid. The error message returned because the specified request parameters are invalid.

For a list of error codes, visit the API Error Center.