Obtains suggestions provided by query governance for optimizing a specified SQL template.

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

  • If you use an Alibaba Cloud SDK, make sure that the aliyun-sdk-core version is later than V2.1.8. We recommend that you use the latest version.
  • The version of your Database Autonomy Service (DAS) SDK must be V2.1.8 or later.
  • If you use an SDK to call the DAS service, you must set the region to cn-shanghai.
  • This operation can be used in the following database services:
    • ApsaraDB RDS for MySQL
    • PolarDB for MySQL
    • ApsaraDB RDS for PostgreSQL

Request parameters

Parameter Type Required Example Description
Action String Yes GetQueryOptimizeSolution

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

Engine String Yes MySQL

The database engine. Valid values:

  • MySQL
  • PolarDB MySQL
  • PostgreSQL
SqlId String Yes 05fecf7e7b3efd123c4d5197035f****

The ID of the SQL template. You can call the GetQueryOptimizeExecErrorStats operation to obtain the SQL template ID.


The tag ID. For more information, see Query governance.

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.

Data Object

Details of the returned entries.

Total Long 1

The total number of returned entries.

PageNo Integer None

A reserved parameter.

PageSize Integer None

A reserved parameter.

Extra String None

A reserved parameter.

List Array of QueryOptimizeSolutions
Level String INFO

The severity level. Valid values:

  • INFO: normal.
  • WARN: warning: critical.

The tag ID. For more information, see Query governance.


The suggestions. For more information, see Query governance.

SolutionExt String None

A reserved parameter.

RequestId String 30FF4E40-17F3-5A51-AB23-43F30D9B****

The ID of the request.

Success String true

Indicates whether the request is successful. Valid values:

  • true
  • false


Sample requests

&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK


JSON format

HTTP/1.1 200 OK

  "Code" : "200",
  "Message" : "Successful",
  "Data" : {
    "Total" : 1,
    "Extra" : "None",
    "List" : [ {
      "Level" : "INFO",
      "RuleId" : "LARGE_ROWS_EXAMINED",
      "SolutionExt" : "None"
    } ]
  "RequestId" : "30FF4E40-17F3-5A51-AB23-43F30D9B****",
  "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.