Queries slow query logs within a specified time range.

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 a sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeSlowSQLLogs

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

DBInstanceId String Yes gp-****************

The ID of the instance.

Note You can call the DescribeDBInstances operation to query details about all AnalyticDB for PostgreSQL instances in a specific region, including instance IDs.
QueryKeywords String No *****

The keywords that are included in the SQL statements to query.

StartTime String Yes 2021-03-10T06:30: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.

Database String No adbpgadmin

The name of the database.

User String No testadmin

The username that is used to log on to the database.

EndTime String Yes 2021-03-17T06:30: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.

PageSize Integer No 30

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

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.

SourceIP String No 192.**.**.121

The source IP address.

ExecuteState String No success

The execution state of the query.

  • success
  • fail
OperationClass String No DQL

The query language. Example: DQL, DML, or DDL.

OperationType String No SELECT

The query type. Example: SELECT.

MinExecuteCost String No 1

The minimum time consumed by a slow SQL statement. Unit: seconds.

MaxExecuteCost String No 1000

The maximum time consumed by a slow SQL statement. Unit: seconds.

Response parameters

Parameter Type Example Description
PageRecordCount Integer 1

The number of SQL log entries on the current page.

RequestId String 07F6177E-****-****-****-0723301340F3

The ID of the request.

PageNumber Integer 1

The page number of the returned page.

Items Array of Item

Details about slow query logs.

OperationClass String DQL

The query language.

ExecuteState String success

The execution state of the query.

ExecuteCost Float 2

The execution duration of the query.

SQLText String select ** from **

The SQL statement.

SourcePort Integer 50514

The source port number.

DBRole String master

The database role.

OperationType String SELECT

The query type.

SourceIP String 192.**.**.121

The source IP address.

SQLPlan String ****

The SQL query plan.

ReturnRowCounts Long 1

The number of entries returned.

DBName String adbpgadmin

The name of the database.

OperationExecuteTime String 2021-03-15T17:02:32Z

The start time of the query execution.

ScanRowCounts Long 1

The number of entries scanned.

AccountName String testadmin

The database account.

QueryId String 111111

The query ID.

Examples

Sample requests

http(s)://gpdb.aliyuncs.com/?Action=DescribeSlowSQLLogs
&DBInstanceId=gp-****************
&StartTime=2021-03-10T06:30Z
&EndTime=2021-03-17T06:30Z
&<Common request parameters>

Sample success responses

XML format

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

<DescribeSlowSQLLogsResponse>
    <PageRecordCount>1</PageRecordCount>
    <RequestId>07F6177E-****-****-****-0723301340F3</RequestId>
    <PageNumber>1</PageNumber>
    <Items>
        <OperationClass>DQL</OperationClass>
        <ExecuteState>success</ExecuteState>
        <ExecuteCost>2</ExecuteCost>
        <SQLText>select ** from **</SQLText>
        <SourcePort>50514</SourcePort>
        <DBRole>master</DBRole>
        <OperationType>SELECT</OperationType>
        <SourceIP>192.**.**.121</SourceIP>
        <SQLPlan>****</SQLPlan>
        <ReturnRowCounts>1</ReturnRowCounts>
        <DBName>adbpgadmin</DBName>
        <OperationExecuteTime>2021-03-15T17:02:32Z</OperationExecuteTime>
        <ScanRowCounts>1</ScanRowCounts>
        <AccountName>testadmin</AccountName>
        <QueryId>111111</QueryId>
    </Items>
</DescribeSlowSQLLogsResponse>

JSON format

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

{
  "PageRecordCount" : 1,
  "RequestId" : "07F6177E-****-****-****-0723301340F3",
  "PageNumber" : 1,
  "Items" : [ {
    "OperationClass" : "DQL",
    "ExecuteState" : "success",
    "ExecuteCost" : 2,
    "SQLText" : "select ** from **",
    "SourcePort" : 50514,
    "DBRole" : "master",
    "OperationType" : "SELECT",
    "SourceIP" : "192.**.**.121",
    "SQLPlan" : "****",
    "ReturnRowCounts" : 1,
    "DBName" : "adbpgadmin",
    "OperationExecuteTime" : "2021-03-15T17:02:32Z",
    "ScanRowCounts" : 1,
    "AccountName" : "testadmin",
    "QueryId" : "111111"
  } ]
}

Error codes

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