Queries all SQL patterns in an AnalyticDB for MySQL cluster within a specific period of time.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeSQLPatterns

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

DBClusterId String Yes am-****************

The ID of the cluster.

Note You can call the DescribeDBClusters operation to query the details of all AnalyticDB for MySQL clusters within a specific region, including cluster IDs.
StartTime String Yes 2021-11-12T00:15:00Z

The beginning of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

Note

  • Only data for the last 14 days can be queried. For example, if the current time is 2021-11-22T12:00:00Z, you can query SQL patterns at a point in time as early as 2021-11-09T12:00:00Z.
  • The interval between the start time and the end time cannot exceed 24 hours.
EndTime String Yes 2021-11-13T00:15:00Z

The end of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

Note The end time must be later than the start time.
RegionId String Yes cn-hangzhou

The region ID of the cluster.

Note You can call the DescribeRegions operation to query the regions and zones supported by AnalyticDB for MySQL, including region IDs.
Keyword String No SELECT

The keyword for the query.

Order String Yes [{"Field":"AverageQueryTime","Type":"Asc"}]

The order by which to sort query results. Specify the parameter value in the JSON string format. Example: [{"Field":"AverageQueryTime","Type":"Asc"}].

  • Field specifies the field by which to sort the query results. Valid values:
    • PatternCreationTime: the earliest commit time of the SQL pattern within the time range to query.
    • AverageQueryTime: the average total amount of time consumed by the SQL pattern within the time range to query.
    • MaxQueryTime: the maximum total amount of time consumed by the SQL pattern within the time range to query.
    • AverageExecutionTime: the average execution duration of the SQL pattern within the time range to query.
    • MaxExecutionTime: the maximum execution duration of the SQL pattern within the time range to query.
    • AveragePeakMemory: the average peak memory usage of the SQL pattern within the time range to query.
    • MaxPeakMemory: the maximum peak memory usage of the SQL pattern within the time range to query.
    • AverageScanSize: the average amount of data scanned based on the SQL pattern within the time range to query.
    • MaxScanSize: the maximum amount of data scanned based on the SQL pattern within the time range to query.
    • QueryCount: the number of queries performed in association with the SQL pattern within the time range to query.
    • FailedCount: the number of failed queries performed in association with the SQL pattern within the time range to query.
  • Type specifies the sorting method. Valid values (case-insensitive):
    • Asc: ascending order
    • Desc: descending order
PageNumber Integer No 1

The number of the page to return. The value must be an integer that is greater than 0.

Note If you leave this parameter empty, the default value 1 is used.
PageSize Integer No 30

The number of entries to return on each page. Valid values:

  • 30
  • 50
  • 100
Note If you leave this parameter empty, the default value 30 is used.
Lang String No zh

The languages available for file titles and some error messages. Default value: zh. Valid values:

  • zh: Simplified Chinese
  • en: English
  • ja: Japanese
  • zh-tw: Traditional Chinese

Response parameters

Parameter Type Example Description
PageNumber Integer 1

The page number of the returned page.

PageSize Integer 30

The number of entries returned on the current page.

TotalCount Integer 1

The total number of entries.

PatternDetails Array of patternDetails

Details of SQL patterns.

SQLPattern String SELECT * FROM KEPLER_META_NODE_STATIC_INFO WHERE elastic_node = ? OR (elastic_node = ? AND enable = ?)

The statement of the SQL pattern.

PatternId String 5575924945138******

The ID of the SQL pattern.

User String reporter

The database username that is used to commit the SQL pattern.

AccessIp String 192.168.xx.xx

The IP address of the SQL client that commits the SQL pattern.

Tables String tpch.orders

The tables scanned based on the SQL pattern.

PatternCreationTime String 2021-11-12 03:06:00

The earliest commit time of the SQL pattern within the query time range.

AverageQueryTime double 23.6666

The average total amount of time consumed by the SQL pattern within the query time range. Unit: milliseconds.

MaxQueryTime Long 2341

The maximum total amount of time consumed by the SQL pattern within the query time range. Unit: milliseconds.

AverageExecutionTime double 234.78

The average execution duration of the SQL pattern within the query time range. Unit: milliseconds.

MaxExecutionTime Long 2142

The maximum execution duration of the SQL pattern within the query time range. Unit: milliseconds.

AveragePeakMemory double 234.22

The average peak memory usage of the SQL pattern within the query time range. Unit: byte.

MaxPeakMemory Long 234149

The maximum peak memory usage of the SQL pattern within the query time range. Unit: byte.

AverageScanSize double 234149.23

The average amount of data scanned based on the SQL pattern within the query time range. Unit: byte.

MaxScanSize Long 234149

The maximum amount of data scanned based on the SQL pattern within the query time range. Unit: byte.

QueryCount Long 345

The number of queries executed in association with the SQL pattern within the query time range.

FailedCount Long 234

The number of failed queries executed in association with the SQL pattern within the query time range.

Blockable Boolean true

Indicates whether the execution of the SQL pattern can be blocked. Valid values:

  • true
  • false
    Note Only SELECT and INSERT statements can be blocked.
RequestId String 6BE0EDD1-0DE6-3EB6-81BF-BFE4F2******

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=DescribeSQLPatterns
&DBClusterId=am-****************
&StartTime=2021-11-12T00:15:00Z
&EndTime=2021-11-13T00:15:00Z
&RegionId=cn-hangzhou
&Keyword=SELECT
&Order=[{"Field":"AverageQueryTime","Type":"Asc"}]
&PageNumber=1
&PageSize=30
&Lang=zh
&<Common request parameters>

Sample success responses

XML format

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

<DescribeSQLPatternsResponse>
    <PageNumber>1</PageNumber>
    <PageSize>30</PageSize>
    <TotalCount>1</TotalCount>
    <PatternDetails>
        <SQLPattern>SELECT * FROM KEPLER_META_NODE_STATIC_INFO WHERE elastic_node = ? OR (elastic_node = ? AND enable = ?)</SQLPattern>
        <PatternId>5575924945138******</PatternId>
        <User>reporter</User>
        <AccessIp>192.168.xx.xx</AccessIp>
        <Tables>tpch.orders</Tables>
        <PatternCreationTime>2021-11-12 03:06:00</PatternCreationTime>
        <AverageQueryTime>23.6666</AverageQueryTime>
        <MaxQueryTime>2341</MaxQueryTime>
        <AverageExecutionTime>234.78</AverageExecutionTime>
        <MaxExecutionTime>2142</MaxExecutionTime>
        <AveragePeakMemory>234.22</AveragePeakMemory>
        <MaxPeakMemory>234149</MaxPeakMemory>
        <AverageScanSize>234149.23</AverageScanSize>
        <MaxScanSize>234149</MaxScanSize>
        <QueryCount>345</QueryCount>
        <FailedCount>234</FailedCount>
        <Blockable>true</Blockable>
    </PatternDetails>
    <RequestId>6BE0EDD1-0DE6-3EB6-81BF-BFE4F2******</RequestId>
</DescribeSQLPatternsResponse>

JSON format

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

{
  "PageNumber" : 1,
  "PageSize" : 30,
  "TotalCount" : 1,
  "PatternDetails" : {
    "SQLPattern" : "SELECT * FROM KEPLER_META_NODE_STATIC_INFO WHERE elastic_node = ? OR (elastic_node = ? AND enable = ?)",
    "PatternId" : "5575924945138******",
    "User" : "reporter",
    "AccessIp" : "192.168.xx.xx",
    "Tables" : "tpch.orders",
    "PatternCreationTime" : "2021-11-12 03:06:00",
    "AverageQueryTime" : 23.6666,
    "MaxQueryTime" : 2341,
    "AverageExecutionTime" : 234.78,
    "MaxExecutionTime" : 2142,
    "AveragePeakMemory" : 234.22,
    "MaxPeakMemory" : 234149,
    "AverageScanSize" : 234149.23,
    "MaxScanSize" : 234149,
    "QueryCount" : 345,
    "FailedCount" : 234,
    "Blockable" : true
  },
  "RequestId" : "6BE0EDD1-0DE6-3EB6-81BF-BFE4F2******"
}

Error codes

For a list of error codes, visit the API Error Center.