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

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 DescribeDiagnosisRecords

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

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 1632931200000

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

Note Only data for the last 14 days can be queried.
EndTime String Yes 1633017540000

The end of the time range to query. Specify the time in the UNIX timestamp format. Unit: 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.
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.
QueryCondition String Yes {"Type":"status","Value":"finished"}

The query conditions for SQL statements, which can be a combination of the Type and Value fields or a combination of the Type, Min, and Max fields. Specify the conditions in the JSON format. Type specifies the query dimension. Valid values for Type: maxCost, status, and cost. Value, Min, or Max specifies the query range for the dimension. Sample values:

  • {"Type":"maxCost","Value":"100"}: queries the top 100 most time-consuming SQL statements. Value can be set only to 100.
  • {"Type":"status","Value":"finished"}: queries executed SQL statements. You can set Value to running or failed to query SQL statements that are being executed or failed to be executed.
  • {"Type":"cost","Min":"10","Max":"200"}: queries SQL statements whose execution durations are between 10 milliseconds and 200 milliseconds. You can also customize the maximum and minimum execution durations.
Keyword String No select

The keyword for the query.

MinPeakMemory Long No 0

The minimum peak memory consumed by the SQL statement. Unit: byte.

MaxPeakMemory Long No 89000000

The maximum peak memory consumed by the SQL statement. Unit: byte.

MinScanSize Long No 0

The minimum amount of data scanned by the SQL statement. Unit: byte.

MaxScanSize Long No 104428198

The maximum amount of data scanned by the SQL statement. Unit: byte.

ResourceGroup String No user_default

The resource group to which the SQL statement belongs.

Note You can call the DescribeDiagnosisDimensions operation to query the resource group, database name, username, and source IP address that are associated with the SQL statement.
UserName String No test_user

The name of the user who executes the SQL statement.

Note You can call the DescribeDiagnosisDimensions operation to query the resource group, database name, username, and source IP address that are associated with the SQL statement.
Database String No adb_demo

The name of the database on which the SQL statement is executed.

Note You can call the DescribeDiagnosisDimensions operation to query the resource group, database name, username, and source IP address that are associated with the SQL statement.
ClientIp String No 59.82.***.***

The source IP address.

Note You can call the DescribeDiagnosisDimensions operation to query the resource group, database name, username, and source IP address that are associated with the SQL statement.
Order String No [{"Field":"StartTime", "Type": "desc" }]

The order by which to sort the SQL statements. The value must be an ordered JSON array that contains the Field and Type fields and is arranged in the same order as the input array. Example: [{"Field":"StartTime, "Type":"desc" }] . The following section describes the fields used in the syntax:

  • Field specifies the field that is used to sort the retrieved entries. Valid values:
    • StartTime: the start time of the execution.
    • Status: the execution status.
    • UserName: the username.
    • Cost: the execution duration.
    • PeakMemory: the peak memory.
    • ScanSize: the amount of scanned data.
    • Database: the name of the database.
    • ClientIp: the source IP address.
    • ResourceGroup: the name of the resource group.
    • QueueTime: the amount of time spent queuing.
    • OutputRows: the number of output rows.
    • OutputDataSize: the amount of output data.
    • ResourceCostRank: the execution duration ranking of operators used in the SQL statement. This field takes effect only when the QueryCondition parameter is set to {"Type":"status","Value":"running"}.
  • Type specifies the sorting method. Valid values (case-insensitive):
    • Desc: descending order
    • Asc: ascending order
PageNumber Integer No 1

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

PageSize Integer No 30

The number of entries to return on each page. Valid values: 30, 50, and 100. Default value: 30.

Lang String No zh

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

  • zh: Simplified Chinese
  • en: English
  • ja: Japanese
  • zh-tw: Traditional Chinese
PatternId Long No 5575924945138******

The ID of the SQL pattern.

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.

Querys Array of Items

Details about the SQL statements.

SQL String SELECT count(*)\nFROM nation

The details of the SQL statement.

Note For performance considerations, an SQL statement cannot exceed 5,120 characters in length. SQL statements that exceed the limit are truncated to the maximum length. You can call the DownloadDiagnosisRecords operation to download the summary information of SQL statements that meet specific search conditions in an AnalyticDB for MySQL cluster, including complete SQL statements.
SQLTruncatedThreshold Long 5120

The maximum allowed length of the SQL statement. The value is fixed to 5,120 characters. SQL statements that exceed the limit are truncated to the maximum length.

Status String finished

The status of the SQL statement. Valid values:

  • running: The SQL statement is being executed.
  • finished: The SQL statement is executed.
  • failed: The SQL statement failed to be executed.
OutputDataSize Long 9

The amount of returned data. Unit: byte.

Cost Long 10

The total amount of time consumed by the query. Unit: milliseconds.

Note The value of this parameter is the cumulative value of the QueuedTime, TotalPlanningTime, and ExecutionTime metrics.
OutputRows Long 1

The number of returned rows.

RcHost String 10.0.***.***:3004

The IP address and port of the AnalyticDB for MySQL frontend node on which the SQL statement is executed.

ScanSize Long 9

The amount of scanned data. Unit: byte.

ProcessId String 2021093000414401000000023503151******

The ID of the query.

StartTime Long 1632933704000

The beginning of the time range in which the SQL statement is executed. The time is in the UNIX timestamp format. Unit: milliseconds.

SQLTruncated Boolean false

Indicates whether the length of the query result exceeds the threshold or whether 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.
Database String adb_demo

The name of the database on which the SQL statement is executed.

ScanRows Long 1

The number of scanned rows.

ResourceCostRank Integer 1

The execution duration ranking of operators used in the SQL statement.

Note This parameter is returned only for SQL statements whose Status value is running.
ClientIp String 59.82.***.***

The source IP address.

PeakMemory Long 16648

The peak memory. Unit: byte.

QueueTime Long 0

The amount of time spent queuing. Unit: milliseconds.

ResourceGroup String user_default

The resource pool to which the SQL statement belongs.

UserName String test_user

The name of the user who executes the SQL statement.

ExecutionTime Long 6

The execution duration of the query. Unit: milliseconds.

TotalPlanningTime Long 4

The amount of time taken to generate execution plans. Unit: milliseconds.

EtlWriteRows Long 0

The number of rows written to the table by the extract, transform, load (ETL) task.

TotalStages Integer 2

The total number of stages generated by the query.

RequestId String 109462AF-B5FA-3D5A-9377-B27E5B******

The ID of the request.

Examples

Sample requests

http(s)://adb.aliyuncs.com/?Action=DescribeDiagnosisRecords
&DBClusterId=am-****************
&StartTime=1632931200000
&EndTime=1633017540000
&QueryCondition={"Type":"status","Value":"running"}
&<Common request parameters>

Sample success responses

XML format

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

<DescribeDiagnosisRecordsResponse>
    <PageSize>30</PageSize>
    <PageNumber>1</PageNumber>
    <TotalCount>1</TotalCount>
    <Querys>
        <Status>finished</Status>
        <UserName>test_user</UserName>
        <TotalPlanningTime>4</TotalPlanningTime>
        <SQLTruncatedThreshold>5120</SQLTruncatedThreshold>
        <PeakMemory>16648</PeakMemory>
        <EtlWriteRows>0</EtlWriteRows>
        <StartTime>1632933704000</StartTime>
        <Cost>10</Cost>
        <ClientIp>59.82.***.***</ClientIp>
        <SQL>SELECT count(*)
FROM nation</SQL>
        <ExecutionTime>6</ExecutionTime>
        <ScanRows>1</ScanRows>
        <TotalStages>2</TotalStages>
        <Database>adb_demo</Database>
        <OutputRows>1</OutputRows>
        <QueueTime>0</QueueTime>
        <RcHost>10.0.***.***:3004</RcHost>
        <ScanSize>9</ScanSize>
        <ProcessId>2021093000414401000000023503151******</ProcessId>
        <OutputDataSize>9</OutputDataSize>
        <SQLTruncated>false</SQLTruncated>
        <ResourceGroup>user_default</ResourceGroup>
    </Querys>
    <RequestId>109462AF-B5FA-3D5A-9377-B27E5B******</RequestId>
</DescribeDiagnosisRecordsResponse>

JSON format

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

{
  "PageSize" : 30,
  "PageNumber" : 1,
  "TotalCount" : 1,
  "Querys" : {
    "Status" : "finished",
    "UserName" : "test_user",
    "TotalPlanningTime" : 4,
    "SQLTruncatedThreshold" : 5120,
    "PeakMemory" : 16648,
    "EtlWriteRows" : 0,
    "StartTime" : 1632933704000,
    "Cost" : 10,
    "ClientIp" : "59.82.***.***",
    "SQL" : "SELECT count(*)\nFROM nation",
    "ExecutionTime" : 6,
    "ScanRows" : 1,
    "TotalStages" : 2,
    "Database" : "adb_demo",
    "OutputRows" : 1,
    "QueueTime" : 0,
    "RcHost" : "10.0.***.***:3004",
    "ScanSize" : 9,
    "ProcessId" : "2021093000414401000000023503151******",
    "OutputDataSize" : 9,
    "SQLTruncated" : false,
    "ResourceGroup" : "user_default"
  },
  "RequestId" : "109462AF-B5FA-3D5A-9377-B27E5B******"
}

Error codes

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