All Products
Search
Document Center

Data Management:GetSQLReviewOptimizeDetail

Last Updated:Aug 28, 2026

Retrieves optimization suggestions for a data change or SQL review ticket.

Operation description

For more information about the SQL review feature, see SQL review.

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

dms:GetSQLReviewOptimizeDetail

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

SQLReviewQueryKey

string

Yes

The key that is used to query the details of optimization suggestions. You can call the ListSQLReviewOriginSQL operation to query the key.

a57e54ec5433475ea3082d882fdb****

Tid

integer

No

The ID of the tenant. You can call the GetUserActiveTenant or ListUserTenants operation to query the ID of the tenant.

1

Response elements

Element

Type

Description

Example

object

RequestId

string

The ID of the request.

0C1CB646-1DE4-4AD0-B4A4-7D47DD52E931

ErrorCode

string

The error code returned.

UnknownError

ErrorMessage

string

The error message returned.

UnknownError

Success

boolean

Indicates whether the request is successful.

true

OptimizeDetail

object

The details of optimization suggestions for SQL statements.

QueryKey

string

The key that is used to query the details of optimization suggestions.

a57e54ec5433475ea3082d882fdb****

InstanceId

integer

The ID of the instance to which the database belongs.

123321

DbId

integer

The ID of the database.

111222

SqlType

string

The type of the SQL statement. Valid values: DELETE, UPDATE, and ALTER_TABLE.

UPDATE

QualityResult

object

The quality of the SQL statement.

ErrorMessage

string

The error message returned.

syntax error

Results

array<object>

The review results based on rules.

array<object>

RuleName

string

The name of the rule. For more information, see SQL review optimization.

SELECT_SUGGEST_ASSIGN_WHERE

Feedback

string

The optimization suggestion for the SQL statement. Valid values:

  • MUST_IMPROVE: The SQL statement must be improved.

  • POTENTIAL_ISSUE: The SQL statement contains potential issues.

  • SUGGEST_IMPROVE: We recommend that you improve the SQL statement.

  • USEDMSTOOLKIT: We recommend that you change schemas without locking tables.

  • USEDMSDML_UNLOCK: We recommend that you change data without locking tables.

  • TABLEINDEXSUGGEST: We recommend that you use SQL statements that use indexes.

MUST_IMPROVE

Comments

string

The comment that is specified when you create the SQL review rule. For more information, see SQL review optimization.

xxx业务规定:查询必须带where条件

Messages

array

The review results.

string

audit information.

xxx表不存在

Scripts

array<object>

The SQL script for data changes.

object

OpType

string

The purpose of the SQL script. The value is set to AddIndex.

AddIndex

Content

string

The content of the SQL script.

alter table xxx add index idx_xx(yyy);

TableName

string

The name of the table.

xxx

RuleType

string

The type of the SQL review rule. Valid values:

  • REVIEW: a rule that is used to review SQL statements based on standards.

  • OPTIMIZE: a rule that is used to provide optimization suggestions.

REVIEW

OccurError

boolean

Indicates whether an error occurs. Valid values:

  • true: An error occurs.

  • false: No error occurs.

false

Examples

Success response

JSON format

{
  "RequestId": "0C1CB646-1DE4-4AD0-B4A4-7D47DD52E931",
  "ErrorCode": "UnknownError",
  "ErrorMessage": "UnknownError",
  "Success": true,
  "OptimizeDetail": {
    "QueryKey": "a57e54ec5433475ea3082d882fdb****",
    "InstanceId": 123321,
    "DbId": 111222,
    "SqlType": "UPDATE",
    "QualityResult": {
      "ErrorMessage": "syntax error",
      "Results": [
        {
          "RuleName": "SELECT_SUGGEST_ASSIGN_WHERE",
          "Feedback": "MUST_IMPROVE",
          "Comments": "xxx业务规定:查询必须带where条件",
          "Messages": [
            "xxx表不存在"
          ],
          "Scripts": [
            {
              "OpType": "AddIndex",
              "Content": "alter table xxx add index idx_xx(yyy);",
              "TableName": "xxx"
            }
          ],
          "RuleType": "REVIEW"
        }
      ],
      "OccurError": false
    }
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.