All Products
Search
Document Center

AnalyticDB:DescribeSqlPattern

Last Updated:Aug 30, 2024

Queries a list of SQL patterns for an AnalyticDB for MySQL cluster within a time range.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
adb:DescribeSqlPatternget
  • DBCluster
    acs:adb:{#regionId}:{#accountId}:dbcluster/{#DBClusterId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
StartTimestringYes

The start date to query. Specify the time in the yyyy-MM-dd format. The time must be in UTC.

Note Only data within the last 30 days can be queried.
2021-08-30
OrderstringNo

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

  • Field specifies the field by which to sort the query results. Valid values:

    • Pattern: the SQL pattern.
    • AccessIP: the IP address of the client.
    • User: the username.
    • QueryCount: the number of queries performed in association with the SQL pattern within the time range to query.
    • AvgPeakMemory: the average peak memory usage of the SQL pattern within the time range to query. Unit: KB.
    • MaxPeakMemory: the maximum peak memory usage of the SQL pattern within the time range to query. Unit: KB.
    • AvgCpuTime: the average execution duration of the SQL pattern within the time range to query. Unit: milliseconds.
    • MaxCpuTime: the maximum execution duration of the SQL pattern within the time range to query. Unit: milliseconds.
    • AvgStageCount: the average number of stages.
    • MaxStageCount: the maximum number of stages.
    • AvgTaskCount: the average number of tasks.
    • MaxTaskCount: the maximum number of tasks.
    • AvgScanSize: the average amount of data scanned based on the SQL pattern within the time range to query. Unit: KB.
    • MaxScanSize: the maximum amount of data scanned based on the SQL pattern within the time range to query. Unit: KB.
  • Type specifies the sorting order. Valid values:

    • Asc: ascending order.
    • Desc: descending order.
Note
  • If you do not specify this parameter, query results are sorted in ascending order of Pattern.

  • If you want to sort query results by AccessIP, you must set the Type parameter to accessip. If you want to sort query results by User, you must leave the Type parameter empty or set it to user.

[{"Field":"Pattern","Type":"Asc"}]
PageNumberintegerNo

The page number. Pages start from page 1. Default value: 1.

1
SqlPatternstringNo

The keyword that is used for the query.

Note If you do not specify this parameter, all SQL patterns of the AnalyticDB for MySQL cluster within the time period specified by StartTime are returned.
SELECT
TypestringNo

The dimension by which to aggregate the SQL patterns. Valid values:

  • user: aggregates the SQL patterns by user.
  • accessip: aggregates the SQL patterns by client IP address.
Note If you do not specify this parameter, the SQL patterns are aggregated by user.
user
DBClusterIdstringYes

The cluster ID.

Note You can call the DescribeDBClusters operation to query the information about all AnalyticDB for MySQL clusters within a region, including cluster IDs.
am-bp1r053byu48p****
PageSizeintegerNo

The number of entries per page. The value must be a positive integer. Default value: 30.

30
RegionIdstringYes

The region ID of the cluster.

Note You can call the DescribeRegions operation to query the most recent region list.
cn-hangzhou

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

PageSizeinteger

The number of entries per page.

30
PageNumberinteger

The page number.

1
TotalCountinteger

The total number of entries returned.

1
Itemsarray<object>

The queried SQL pattern.

object
AvgStageCountstring

The average number of stages.

2
MaxCpuTimestring

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

17
AccessIPstring

The IP address of the client.

Note This parameter is returned only when Type is set to accessip.
100.104.***.***
AvgScanSizestring

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

0
MaxScanSizestring

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

0
MaxPeakMemorystring

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

480096
AvgCpuTimestring

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

1.0625
Userstring

The username.

Note This parameter is returned only when Type is left empty or set to user.
test_acc
AvgPeakMemorystring

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

240048
MaxStageCountstring

The maximum number of stages.

2
MaxTaskCountstring

The maximum number of tasks.

2
InstanceNamestring

The cluster ID.

am-bp1r053byu48p****
QueryCountstring

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

16
ReportDatestring

The start date of the query.

2021-08-30
Patternstring

The SQL pattern.

SELECT table_name, table_schema AS schema_name, create_time, create_time AS last_ddl_time, table_comment AS description , ceil((data_length + index_length) / ? / ?) AS store_capacity , data_length AS data_bytes, index_length AS index_bytes, table_collation AS collation, auto_increment, table_rows AS num_rows , engine FROM information_schema.tables WHERE table_type != ? AND table_schema = ? AND table_name IN (?) ORDER BY 1
AvgTaskCountstring

The average number of tasks.

2
RequestIdstring

The request ID.

B6F2D1B4-2C9F-5622-B424-5E7965******

Examples

Sample success responses

JSONformat

{
  "PageSize": 30,
  "PageNumber": 1,
  "TotalCount": 1,
  "Items": [
    {
      "AvgStageCount": "2",
      "MaxCpuTime": "17",
      "AccessIP": "100.104.***.***",
      "AvgScanSize": "0",
      "MaxScanSize": "0",
      "MaxPeakMemory": "480096",
      "AvgCpuTime": "1.0625",
      "User": "test_acc",
      "AvgPeakMemory": "240048",
      "MaxStageCount": "2",
      "MaxTaskCount": "2",
      "InstanceName": "am-bp1r053byu48p****",
      "QueryCount": "16",
      "ReportDate": "2021-08-30",
      "Pattern": "SELECT table_name, table_schema AS schema_name, create_time, create_time AS last_ddl_time, table_comment AS description , ceil((data_length + index_length) / ? / ?) AS store_capacity , data_length AS data_bytes, index_length AS index_bytes, table_collation AS collation, auto_increment, table_rows AS num_rows , engine FROM information_schema.tables WHERE table_type != ? AND table_schema = ? AND table_name IN (?) ORDER BY 1",
      "AvgTaskCount": "2"
    }
  ],
  "RequestId": "B6F2D1B4-2C9F-5622-B424-5E7965******"
}

Error codes

For a list of error codes, visit the Service error codes.