Queries SQL templates that failed to be executed.

  • If you use an Alibaba Cloud SDK or a Database Autonomy Service (DAS) SDK to call this API operation, we recommend that you use the latest version of the SDK.
  • If you use an SDK to call API operations of DAS, you must set the region ID to cn-shanghai.
  • This operation is applicable to the following database services:
    • ApsaraDB RDS for MySQL
    • PolarDB for MySQL
    • ApsaraDB RDS for PostgreSQL

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesGetQueryOptimizeExecErrorStats

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

EngineStringYesMySQL

The database engine. Valid values:

  • MySQL
  • PolarDBMySQL
  • PostgreSQL
InstanceIdsStringNorm-2ze8g2am97624****

The instance IDs. Separate multiple IDs with commas (,).

KeywordsStringNoselect update

The keywords of the SQL templates. Separate multiple keywords with spaces.

LogicalOperatorStringNoor

The logical relationship between multiple keywords. Valid values:

  • or
  • and
DbNamesStringNotestdb01

The name of the database to be queried.

TimeStringYes1642953600000

The end of the time range to query. Specify the time in the UNIX timestamp format. Unit: milliseconds.

PageSizeStringYes10

The number of entries to return on each page. Default value: 10.

PageNoStringYes1

The number of the page to return. Pages start from page 1. Default value: 1.

OrderByStringNoerror_count

The field by which to sort the returned entries. Only error_count is supported, which indicates that the entries are sorted based on the number of failed executions.

AscStringNotrue

Specifies whether to sort the returned entries in ascending order. Default value: true. Valid values:

  • true: sorts the returned entries in ascending order.
  • false: does not sort the returned entries in ascending order.
RegionStringNocn-china

The region in which the instance resides. Valid values:

  • cn-china: Chinese mainland
  • cn-hongkong: China (Hong Kong)
  • ap-southeast-1: Singapore

This parameter is valid only if the InstanceIds parameter is left empty. If you do not specify the InstanceIds parameter, the system obtains data from the region set by the Region parameter. By default, the Region parameter is set to cn-china. If you have specified the InstanceIds parameter, the specified Region parameter becomes invalid and the system obtains data from the region in which the first specified instance resides.

Note If your instances reside in the regions inside the Chinese mainland, set this parameter to cn-china.

Response parameters

ParameterTypeExampleDescription
CodeString200

The HTTP status code returned.

MessageStringSuccessful

The message that is returned for the request.

DataObject

The detailed information, including the error codes and the number of entries that are returned.

TotalLong19

The total number of returned entries.

PageNoInteger1

The page number of the returned page.

PageSizeInteger10

The number of entries returned on each page.

ExtraStringNone

A reserved parameter.

ListArray of QueryOptimizeExecErrorStats

The information about the SQL templates that failed to execute.

InstanceIdStringrm-2ze8g2am97624****

The ID of the instance.

InstanceNameStringtest01

The alias of the instance.

DbnameStringtestdb01

The name of the database.

SqlIdString2e8147b5ca2dfc640dfd5e43d96a****

The ID of the SQL template.

SqlTextStringselect * from test1

The content of the SQL template.

ErrorCodeString1146

The error code returned.

ErrorCountLong10

The number of errors.

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

The ID of the request.

SuccessStringtrue

Indicates whether the request was successful. Valid values:

  • true: The request was successful.
  • false: The request failed.

Examples

Sample requests

http(s)://das.cn-shanghai.aliyuncs.com/?Action=GetQueryOptimizeExecErrorStats
&Engine=MySQL
&InstanceIds=rm-2ze8g2am97624****
&Keywords=select update
&LogicalOperator=or
&DbNames=testdb01
&Time=1642953600000
&PageSize=10
&PageNo=1
&OrderBy=error_count
&Asc=true
&Region=cn-china
&Common request parameters

Sample success responses

XML format

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

<GetQueryOptimizeExecErrorStatsResponse>
    <Code>200</Code>
    <Message>Successful</Message>
    <Data>
        <Total>19</Total>
        <PageNo>1</PageNo>
        <PageSize>10</PageSize>
        <Extra>None</Extra>
        <List>
            <InstanceId>rm-2ze8g2am97624****</InstanceId>
            <InstanceName>test01</InstanceName>
            <Dbname>testdb01</Dbname>
            <SqlId>2e8147b5ca2dfc640dfd5e43d96a****</SqlId>
            <SqlText>select * from test1</SqlText>
            <ErrorCode>1146</ErrorCode>
            <ErrorCount>10</ErrorCount>
        </List>
    </Data>
    <RequestId>B6D17591-B48B-4D31-9CD6-9B9796B2****</RequestId>
    <Success>true</Success>
</GetQueryOptimizeExecErrorStatsResponse>

JSON format

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

{
  "Code" : "200",
  "Message" : "Successful",
  "Data" : {
    "Total" : 19,
    "PageNo" : 1,
    "PageSize" : 10,
    "Extra" : "None",
    "List" : [ {
      "InstanceId" : "rm-2ze8g2am97624****",
      "InstanceName" : "test01",
      "Dbname" : "testdb01",
      "SqlId" : "2e8147b5ca2dfc640dfd5e43d96a****",
      "SqlText" : "select * from test1",
      "ErrorCode" : "1146",
      "ErrorCount" : 10
    } ]
  },
  "RequestId" : "B6D17591-B48B-4D31-9CD6-9B9796B2****",
  "Success" : "true"
}

Error codes

HTTP status codeError codeError messageDescription
400InvalidParamsThe request parameters are invalid.The error message returned because the specified request parameters are invalid.

For a list of error codes, see Service error codes.