All Products
Search
Document Center

AnalyticDB:DescribeDiagnosisRecords

Last Updated:Jan 14, 2026

Queries the summary of SQL statements that meet specified conditions in an AnalyticDB for MySQL cluster.

Operation description

For information about service endpoints, see Endpoints.

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:DescribeDiagnosisRecords

list

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

DBClusterId

string

Yes

The ID of the Enterprise Edition, Basic Edition, or Data Lakehouse Edition cluster.

Note

Call the DescribeDBClusters operation to view the details of all clusters in your account, including cluster IDs.

amv-bp1scs48yc125****

StartTime

string

No

The start of the time range to query. Specify the time in the UNIX timestamp format. The time must be in milliseconds.

Note

Only data from the last 14 days can be queried.

1632931200000

EndTime

string

No

The end of the time range to query. Specify the time in the UNIX timestamp format. The time must be in milliseconds.

Note
  • The end time must be later than the start time.

  • The interval between the start time and the end time cannot exceed 24 hours.

1633017540000

RegionId

string

Yes

The region ID.

Note

Call the DescribeRegions operation to view the regions and zones supported by AnalyticDB for MySQL, including region IDs.

cn-hangzhou

QueryCondition

string

No

The conditions for the SQL query. This parameter is a JSON string that contains fields such as Type, Value, Min, and Max. The Type field indicates the query dimension. Valid values for Type: maxCost, status, and cost. The Value, Min, and Max fields specify the query range for the dimension. Valid values:

  • {"Type":"maxCost","Value":"100"}: queries the details of the top 100 SQL statements that have the longest execution durations. The Value field can only be set to 100.

  • {"Type":"status","Value":"finished"}: queries the details of completed SQL statements. You can also set Value to running or failed to query SQL statements that are running or have failed.

  • {"Type":"cost","Min":"10","Max":"200"}: queries the details of SQL statements whose execution durations are between 10 ms and 200 ms. You can customize the minimum and maximum execution durations. Unit: milliseconds.

{"Type":"status","Value":"finished"}

Keyword

string

No

Filters the queries by the keywords contained in the SQL statements.

select

MinPeakMemory

integer

No

The minimum peak memory of the SQL statement. Unit: bytes.

0

MaxPeakMemory

integer

No

The maximum peak memory of the SQL statement. Unit: bytes.

89000000

MinScanSize

integer

No

The minimum scan size of the SQL statement. Unit: bytes.

0

MaxScanSize

integer

No

The maximum scan size of the target SQL statement. Unit: bytes.

1024000000

ResourceGroup

string

No

The resource group to which the SQL statement belongs.

Note

Call the DescribeDiagnosisDimensions operation to view the resource groups, database names, usernames, and source IP addresses for the SQL statements that meet the specified query conditions.

user_default

UserName

string

No

The username used to execute the SQL statement. Call the DescribeDiagnosisDimensions operation to view the resource groups, database names, usernames, and source IP addresses for the SQL statements that meet the specified query conditions.

test_user

Database

string

No

The database where the SQL statement is executed.

Note

Call the DescribeDiagnosisDimensions operation to view the resource groups, database names, usernames, and source IP addresses for the SQL statements that meet the specified query conditions.

adb_demo

ClientIp

string

No

The source IP address.

Note

Call the DescribeDiagnosisDimensions operation to view the resource groups, database names, usernames, and source IP addresses for the SQL statements that meet the specified query conditions.

59.82.XX.XX

Order

string

No

The sorting order of the SQL statements. This parameter is a JSON array that is ordered by the sequence of the input array. It contains the Field and Type fields. Example: [{"Field":"StartTime", "Type": "desc" }]. The fields are described as follows:

  • Field specifies the field by which to sort the SQL statements. Valid values:

    • StartTime: the start time of the execution.

    • Status: the execution state.

    • UserName: the username.

    • Cost: the execution duration.

    • PeakMemory: the peak memory.

    • ScanSize: the amount of scanned data.

    • Database: the database name.

    • ClientIp: the source IP address.

    • ResourceGroup: the resource group.

    • QueueTime: the amount of time that the query waited in a queue.

    • OutputRows: the number of output rows.

    • OutputDataSize: the amount of output data.

    • ResourceCostRank: the ranking of the execution duration of an operator in the SQL statement. This field is returned only when QueryCondition is set to {"Type":"status","Value":"running"}.

  • Type specifies the sorting type. Valid values (case-insensitive):

    • Desc: descending order.

    • Asc: ascending order.

[{"Field":"StartTime", "Type": "desc" }]

PageNumber

integer

No

The page number. The value must be an integer that is greater than 0. Default value: 1.

1

PageSize

integer

No

The number of entries per page. Valid values:

  • 30 (default)

  • 50

  • 100

30

Lang

string

No

The language of the file title and some error messages in the downloaded file. Valid values:

  • zh: Simplified Chinese (default).

  • en: English.

  • ja: Japanese.

  • zh-tw: Traditional Chinese.

zh

PatternId

string

No

The ID of the SQL pattern.

5575924945138******

Response elements

Element

Type

Description

Example

object

PageNumber

integer

The page number. The value is an integer that is greater than 0. Default value: 1.

1

PageSize

integer

The number of entries per page. Valid values:

  • 30 (default)

  • 50

  • 100

30

TotalCount

integer

The total number of entries.

1

Querys

array<object>

The list of SQL statement details.

array<object>

A list of queries.

SQL

string

The details of the SQL statement.

Note

For performance, an SQL statement can be up to 5,120 characters long. Longer statements are truncated. Call the DownloadDiagnosisRecords operation to download the summary information of SQL statements that meet the specified conditions, including the complete SQL statements.

SELECT count(*)\nFROM nation

SQLTruncatedThreshold

integer

The truncation threshold for the SQL statement. The value is fixed at 5,120 characters. SQL statements that exceed this limit are truncated.

5120

Status

string

The state of the SQL statement. Valid values:

  • running: The statement is running.

  • finished: The statement is complete.

  • failed: The statement failed to be executed.

finished

OutputDataSize

integer

The amount of returned data. Unit: bytes.

9

Cost

integer

The total execution duration of the query. Unit: milliseconds.

Note

This duration is the sum of QueuedTime, TotalPlanningTime, and ExecutionTime.

10

OutputRows

integer

The number of returned rows.

1

RcHost

string

The IP address and port number of the AnalyticDB for MySQL frontend node that is used to execute the SQL statement.

10.0.XX.XX:3004

ScanSize

integer

The amount of scanned data. Unit: bytes.

9

ProcessId

string

The query ID.

2021093000414401000000023503151******

StartTime

integer

The start time of the SQL execution. This value is a UNIX timestamp. Unit: milliseconds.

1632933704000

SQLTruncated

boolean

Indicates whether the length of the query result exceeds the threshold. If the length exceeds the threshold, the query result is truncated. Valid values:

  • true: The length of the query result exceeds the threshold.

  • false: The length of the query result does not exceed the threshold.

false

Database

string

The name of the database where the SQL statement is executed.

adb_demo

ScanRows

integer

The number of scanned rows.

1

ResourceCostRank

integer

The ranking of the execution duration of an operator in the SQL statement.

Note

This parameter is returned only for SQL statements that are in the running state.

1

ClientIp

string

The source IP address.

59.82.XX.XX

PeakMemory

integer

The peak memory. Unit: bytes.

16648

QueueTime

integer

The amount of time that the query waited in a queue before execution. Unit: milliseconds (ms).

6

ResourceGroup

string

The resource pool to which the SQL statement belongs.

user_default

UserName

string

The username used to execute the SQL statement.

test_user

ExecutionTime

integer

The execution duration of the query. Unit: milliseconds (ms).

6

TotalPlanningTime

integer

The amount of time that was required to generate the execution plan. Unit: milliseconds (ms).

4

EtlWriteRows

integer

The number of rows written to a table in an ETL task.

0

TotalStages

integer

The total number of stages generated for the query.

2

QueryProperties

array<object>

The list of properties that are in effect for the current query.

Note

For a list of common properties, see Config and Hint configuration parameters.

object

The description of the property key-value pair.

Name

string

The property name.

max_select_items_count

Value

string

The property value.

1024

PatternId

string

The ID of the SQL pattern.

Note

Call the DescribePatternPerformance operation to view the detailed execution metrics of the SQL pattern within a specified time range.

-5575924945138******

RequestId

string

The request ID.

7F88BEFA-CF0B-5C95-8BB1-92EC9F09E40D

Examples

Success response

JSON format

{
  "PageNumber": 1,
  "PageSize": 30,
  "TotalCount": 1,
  "Querys": [
    {
      "SQL": "SELECT count(*)\\nFROM nation",
      "SQLTruncatedThreshold": 5120,
      "Status": "finished",
      "OutputDataSize": 9,
      "Cost": 10,
      "OutputRows": 1,
      "RcHost": "10.0.XX.XX:3004",
      "ScanSize": 9,
      "ProcessId": "2021093000414401000000023503151******",
      "StartTime": 1632933704000,
      "SQLTruncated": false,
      "Database": "adb_demo",
      "ScanRows": 1,
      "ResourceCostRank": 1,
      "ClientIp": "59.82.XX.XX",
      "PeakMemory": 16648,
      "QueueTime": 6,
      "ResourceGroup": "user_default",
      "UserName": "test_user",
      "ExecutionTime": 6,
      "TotalPlanningTime": 4,
      "EtlWriteRows": 0,
      "TotalStages": 2,
      "QueryProperties": [
        {
          "Name": "max_select_items_count",
          "Value": "1024"
        }
      ],
      "PatternId": "-5575924945138******"
    }
  ],
  "RequestId": "7F88BEFA-CF0B-5C95-8BB1-92EC9F09E40D"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.