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.

RuleIds String Yes LARGE_ROWS_EXAMINED

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.
RuleId String LARGE_ROWS_EXAMINED

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

Solution String LARGE_ROWS_EXAMINED_SOLUTION

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

Examples

Sample requests

http(s)://das.cn-shanghai.aliyuncs.com/?Action=GetQueryOptimizeSolution
&Engine=MySQL
&SqlId=05fecf7e7b3efd123c4d5197035f****
&RuleIds=LARGE_ROWS_EXAMINED
&Common request parameters

Sample success responses

XML format

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

<GetQueryOptimizeSolutionResponse>
    <Code>200</Code>
    <Message>Successful</Message>
    <Data>
        <Total>1</Total>
        <Extra>None</Extra>
        <List>
            <Level>INFO</Level>
            <RuleId>LARGE_ROWS_EXAMINED</RuleId>
            <Solution>LARGE_ROWS_EXAMINED_SOLUTION</Solution>
            <SolutionExt>None</SolutionExt>
        </List>
    </Data>
    <RequestId>30FF4E40-17F3-5A51-AB23-43F30D9B****</RequestId>
    <Success>true</Success>
</GetQueryOptimizeSolutionResponse>

JSON format

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

{
  "Code" : "200",
  "Message" : "Successful",
  "Data" : {
    "Total" : 1,
    "Extra" : "None",
    "List" : [ {
      "Level" : "INFO",
      "RuleId" : "LARGE_ROWS_EXAMINED",
      "Solution" : "LARGE_ROWS_EXAMINED_SOLUTION",
      "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.