All Products
Search
Document Center

AnalyticDB:DescribeSqlPattern

Last Updated:Aug 28, 2026

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

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

adb:DescribeSqlPattern

get

DBCluster

acs:adb:{#regionId}:{#accountId}:dbcluster/{#DBClusterId}

None None

Request parameters

Parameter

Type

Required

Description

Example

StartTime

string

Yes

The query start date, in yyyy-MM-dd format (UTC).

Note

Only data within the last 30 days can be queried.

2021-08-30

Order

string

No

The sort order for query results. Specify as a JSON string, such as [{"Field":"Pattern","Type":"Asc"}]. Parameters:

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

    • Pattern: the SQL pattern.

    • AccessIP: the IP address of the client.

    • User: the username.

    • QueryCount: the number of queries for the SQL pattern within the specified time range.

    • AvgPeakMemory: the average peak memory usage of the SQL pattern within the specified time range. Unit: KB.

    • MaxPeakMemory: the maximum peak memory usage of the SQL pattern within the specified time range. Unit: KB.

    • AvgCpuTime: the average execution duration of the SQL pattern within the specified time range. Unit: milliseconds.

    • MaxCpuTime: the maximum execution duration of the SQL pattern within the specified time range. 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 data scanned for the SQL pattern within the specified time range. Unit: KB.

    • MaxScanSize: the maximum data scanned for the SQL pattern within the specified time range. Unit: KB.

  • Type specifies the sorting order. Valid values:

    • Asc: ascending order.

    • Desc: descending order.

Note
  • If not specified, results are sorted by Pattern in ascending order.

  • 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"}]

PageNumber

integer

No

The page number, starting from 1. Default value: 1.

1

SqlPattern

string

No

The keyword to filter SQL patterns.

Note

If not specified, all SQL patterns for the cluster within the time period specified by StartTime are returned.

SELECT

Type

string

No

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 not specified, SQL patterns are aggregated by user.

user

DBClusterId

string

Yes

The cluster ID.

Note

You can call the DescribeDBClusters operation to query AnalyticDB for MySQL clusters within a region, including cluster IDs.

am-bp1r053byu48p****

PageSize

integer

No

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

30

RegionId

string

Yes

The region ID of the cluster.

Note

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

Response elements

Element

Type

Description

Example

object

The response parameters.

PageSize

integer

The number of entries per page.

30

PageNumber

integer

The page number.

1

TotalCount

integer

The total number of entries returned.

1

Items

array<object>

The queried SQL pattern.

object

AvgStageCount

string

The average number of stages.

2

MaxCpuTime

string

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

17

AccessIP

string

The IP address of the client.

Note

This parameter is returned only when Type is set to accessip.

100.104.***.***

AvgScanSize

string

The average data scanned for the SQL pattern within the query time range. Unit: KB.

0

MaxScanSize

string

The maximum data scanned for the SQL pattern within the query time range. Unit: KB.

0

MaxPeakMemory

string

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

480096

AvgCpuTime

string

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

1.0625

User

string

The username.

Note

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

test_acc

AvgPeakMemory

string

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

240048

MaxStageCount

string

The maximum number of stages.

2

MaxTaskCount

string

The maximum number of tasks.

2

InstanceName

string

The cluster ID.

am-bp1r053byu48p****

QueryCount

string

The number of queries for the SQL pattern within the query time range.

16

ReportDate

string

The start date of the query.

2021-08-30

Pattern

string

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

AvgTaskCount

string

The average number of tasks.

2

RequestId

string

The request ID.

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

Examples

Success response

JSON format

{
  "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

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.