Help Center/ Relational Database Service/ API Reference/ API v3 (Recommended)/ DB Instance Management/ Querying SQL Statement Statistics (RDS for PostgreSQL)
Updated on 2025-10-21 GMT+08:00

Querying SQL Statement Statistics (RDS for PostgreSQL)

Function

This API is used to query SQL statement statistics of a DB instance.

URI

  • URI format

    GET /v3/{project_id}/instances/{instance_id}/sql-statistics

  • Parameter description
    Table 1 Parameters

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Definition

    Project ID of a tenant in a region.

    To obtain the value, see Obtaining a Project ID.

    Constraints

    N/A

    Range

    N/A

    Default Value

    N/A

    instance_id

    Yes

    Definition

    Instance ID.

    Constraints

    N/A

    Range

    N/A

    Default Value

    N/A

Request

Table 2 Parameters

Parameter

Mandatory

Type

Description

offset

No

Integer

Definition

Index offset. The query starts from the next piece of data indexed by this parameter.

Constraints

The value must be a non-negative number.

Range

An integer greater than or equal to 0

Default Value

0

limit

No

Integer

Definition

Number of records returned by a query.

Constraints

N/A

Range

The default value is 1000. The value cannot be a negative number. The minimum value is 1, and the maximum value is 1000.

Default Value

1000

Example Request

Query SQL statement statistics.

GET https://{Endpoint}/v3/0483b6b16e954cb88930a360d2c4e663/instances/794c38e5309344818f4b33b86ebce9b4in03/sql-statistics

Response

  • Normal response
    Table 3 Parameters

    Parameter

    Type

    Description

    reset_view_last_time

    Long

    Definition

    Last reset time.

    Range

    N/A

    total_count

    Integer

    Definition

    Total number of records in the SQL statistics list.

    Range

    N/A

    schemas

    Array of objects

    Definition

    Calling result. For details, see Table 4.

    Table 4 schemas field description

    Parameter

    Type

    Description

    user_name

    String

    Definition

    Username.

    Range

    N/A

    database

    String

    Definition

    Database name.

    Range

    N/A

    query_id

    String

    Definition

    Internal hash code calculated by the SQL parse tree.

    Range

    N/A

    calls

    Long

    Definition

    Number of calls.

    Range

    N/A

    query

    String

    Definition

    Text format of an SQL statement.

    Range

    N/A

    rows

    Long

    Definition

    Scanned rows.

    Range

    N/A

    can_use

    double

    Definition

    Whether SQL throttling can be applied.

    Range

    N/A

  • Example normal response
    {
      "reset_view_last_time": 1561561651651,
      "total_count": 1,
      "list": [
        {
          "user_name": "root",
          "database": "data_test",
          "query_id": "4454541510",
          "calls": 1111,
          "query": "select pg_sleep(222);",
          "rows": 111,
          "can_use": true
        }
      ]
    }

Status Code

Error Code

For details, see Error Codes.