All Products
Search
Document Center

Database Autonomy Service:GetSqlOptimizeAdvice

Last Updated:Aug 25, 2026

Queries the diagnostic suggestions generated by the DAS automatic SQL optimization feature.

Operation description

The SQL diagnostics feature provides instance diagnosis suggestions. You can use the suggestions to optimize instance indexes. For details, see Automatic SQL optimization.

Note

You can invoke this operation only to query diagnostic suggestions generated by the DAS automatic SQL optimization feature.

Before you begin:

  • The database DPI engine is RDS MySQL or PolarDB for MySQL.

  • If you use the China site (aliyun.com) or DAS SDK, use the latest version.

  • When you invoke DAS by using the SDK, set the region to cn-shanghai.

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:GetSqlOptimizeAdvice

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

ConsoleContext

string

No

A reserved parameter.

None

Engine

string

No

The database engine. Valid values:

  • MySQL: RDS MySQL.

  • PolarDBMySQL: PolarDB for MySQL.

MySQL

InstanceIds

string

No

The instance ID.

Note

Only RDS MySQL and PolarDB for MySQL instances are supported.

rm-2ze1jdv45i7l6****

StartDt

string

No

The start date of the query. Format: yyyyMMdd (UTC).

  • If this parameter is left empty, the default value is the day before the current date.

  • You can only query data from the day before the current date or earlier.

20210916

EndDt

string

No

The end date of the query. Format: yyyyMMdd (UTC).

  • If this parameter is left empty, the default value is the day before the current date.

  • You can only query data from the day before the current date or earlier. The interval between the start date and the end date cannot exceed 30 days.

20210917

Region

string

No

The region to which the instance belongs. Valid values:

  • cn-china: the Chinese mainland.

  • cn-hongkong: Hong Kong (China).

  • ap-southeast-1: Singapore.

This parameter takes effect only when the InstanceIds request parameter is left empty. If InstanceIds is left empty, data is retrieved based on the region specified by the Region parameter. The default region is cn-china. If InstanceIds is not empty, data is retrieved based on the region of the first instance specified by InstanceIds, even if the Region parameter is set.

Note

For instances created in regions within the Chinese mainland, set this parameter to cn-china.

cn-china

Response elements

Element

Type

Description

Example

object

Code

string

The status code returned.

200

Message

string

The message returned for the request.

Note

If the request is successful, Successful is returned. If the request fails, an error message is returned, such as an error code.

Successful

Data

object

The details, including the total number of entries and error codes.

Status

string

The task status. Valid values:

  • INIT: initializing.

  • RUNNING: running.

  • FINISH: completed.

  • FAILED: failed.

FINISH

StatusCode

string

The task status code. Valid values:

  • NO_DATA: no data available.

  • INTERNAL_ERROR: internal error.

  • SUCCESS: successful.

SUCCESS

DownloadUrl

string

The download URL of the file.

https://das-sql-optimize.oss-cn-shanghai.aliyuncs.com/adb/oss_sql_optimize_advice/1083*******

CreateTime

string

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

1632303861000

ExpireTime

string

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

Note

The file expires three days after the task is created.

1632563061000

TaskId

string

The task ID.

2021091710461519216****

RequestId

string

The request ID.

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

Success

string

Indicates whether the request is successful. Valid values:

  • true: successful.

  • false: failed.

true

Examples

Success response

JSON format

{
  "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 request parameters are invalid.
403 NoPermission You are not authorized to do this action. You do not have the permissions to perform this operation.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.