All Products
Search
Document Center

AnalyticDB:DescribeActiveSQLRecords

Last Updated:Nov 05, 2025

Queries active SQL records.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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:
    • For mandatory resource types, indicate with a prefix of * .
    • 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
gpdb:DescribeActiveSQLRecordsget
*DBInstance
acs:gpdb:*:{#accountId}:dbinstance/{#DBInstanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
DBInstanceIdstringYes

The instance ID.

Note You can call the DescribeDBInstances operation to query the information about all AnalyticDB for PostgreSQL instances within a region, including instance IDs.
gp-bp12ga6v69h86****
DatabasestringNo

The name of the database.

testdb
UserstringNo

The name of the database account.

testuser
StartTimestringNo

The beginning of the time range to query. Specify the time in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

2021-08-03T09:30Z
EndTimestringNo

The end of the time range to query. Specify the time in the yyyy-MM-ddTHH:mm:ssZ format. The end time must be later than the start time.

2022-05-07T07:59Z
KeywordstringNo

The keyword used to filter queries.

SELECT
MinDurationstringNo

The minimum amount of time consumed by traces. Unit: milliseconds.

300
MaxDurationstringNo

The maxmum amount of time consumed by traces. Unit: milliseconds.

600
OrderstringNo

The field used to sort lock diagnostics records and the sorting order.

Default value: {"Field":"StartTime","Type":"Desc"}, which indicates that lock diagnostics records are sorted by the start time in descending order. No other values are supported.

{"Field":"StartTime","Type":"Desc"}

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The request ID.

ABB39CC3-4488-4857-905D-2E4A051D0521
DBInstanceIdstring

The instance ID.

gp-bp***************
Queriesarray<object>

The queried SQL records.

queryobject

The queried SQL record.

PIDstring

The progress ID.

6164
SessionIDstring

The session ID.

6612
Statestring

The status of the asynchronous request. Valid values:

  • running
  • block
running
QueryStartstring

The start time of the query.

2022-05-07T06:59Z
QueryDurationstring

The execution duration of the query. Unit: seconds.

60s
Querystring

The SQL statement of the query.

Select * from t1,t2 where t1.id=t2.id;
Userstring

The name of the database account.

testuser
Databasestring

The name of the database.

xg_analyse
ClientAddrstring

The IP address of the client.

0.0.0.0
SqlTruncatedstring

Indicates whether the SQL statement is truncated. Valid values:

  • true
  • false
false
SqlTruncatedThresholdstring

The threshold that is used to truncate the SQL statement.

1024

Examples

Sample success responses

JSONformat

{
  "RequestId": "ABB39CC3-4488-4857-905D-2E4A051D0521",
  "DBInstanceId": "gp-bp***************",
  "Queries": [
    {
      "PID": 6164,
      "SessionID": 6612,
      "State": "running",
      "QueryStart": "2022-05-07T06:59Z",
      "QueryDuration": "60s",
      "Query": "Select * from t1,t2 where t1.id=t2.id;",
      "User": "testuser",
      "Database": "xg_analyse",
      "ClientAddr": "0.0.0.0",
      "SqlTruncated": false,
      "SqlTruncatedThreshold": 1024
    }
  ]
}

Error codes

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