• Relational Database Service

rds
  1. Help Center
  2. Relational Database Service
  3. API Reference
  4. API v1
  5. Log Information Queries
  6. Querying Database Slow Logs

Querying Database Slow Logs

Function

This API is used to query database slow logs.

URI

  • URI format

    PATH: /rds/{versionId}/{project_id}/instances/{instanceId}/slowlog

    Method: GET

  • Parameter description
    Table 1 Parameter description

    Name

    Mandatory

    Description

    versionId

    Yes

    Specifies the API version. It is case-sensitive and the value is v1.

    project_id

    Yes

    Specifies the project ID of a tenant in a region.

    instanceId

    Yes

    Specifies the ID of the queried DB instance.

  • Restrictions

    The following DB engines are supported:

    • MySQL
    • PostgreSQL
    • Microsoft SQL Server

Request

  • Parameter description
    Table 2 Parameter description

    Name

    Mandatory

    Description

    sftype

    No

    Specifies the statement type. Its value can be empty, INSERT, UPDATE, SELECT, DELETE, or CREATE. If the value is empty, all statement types exist.

    top

    No

    Specifies how many records are returned.

    • If this parameter is specified, the value range is from 1 to 50.
    • If this parameter is not specified, the first 10 records are returned.
  • Request example
    /rds/v1/68e3010955d748099f62a0df726fe09b/instances/02e47383-9222-4d29-bf5b-54b3013b0f71/slowlog?sftype=&top=10

Normal Response

  • Parameter description
    Table 3 Parameter description

    Name

    Type

    Description

    slowLogList

    List data structure. For details, see Table 4.

    Indicates detailed information.

    totalRecord

    Int

    Indicates the total number of records.

    Table 4 slowLogList field data structure description

    Name

    Type

    Description

    count

    String

    Indicates the number of executions.

    time

    String

    Indicates the average execution duration.

    lockTime

    String

    Indicates the average waiting time before locking.

    rowsSent

    String

    Indicates the average number of rows contained in a result.

    rowsExamined

    String

    Indicates the average number of scanned rows.

    database

    String

    Indicates the database which the slow log belongs to.

    users

    String

    Indicates the account.

    querySample

    String

    Indicates the execution syntax.

  • Response example
    {    "slowLogList": [
            {
                "count": " 409  (99.76%)",
                "time": "1.29",
                "lockTime": " 0 ",
                "rowsSent": " 0 ",
                "rowsExamined": " 0 ",
                "database": " ",
                "users": " \trdsBackup@localhost  : 100.00% (409) of query, 99.76% (409) of all users",
                "querySample": "flush logs;"
            },
            {
                "count": " 1  (0.24%)",
                "time": "5.0",
                "lockTime": " 0 ",
                "rowsSent": " 1 ",
                "rowsExamined": " 0 ",
                "database": " ",
                "users": " \trdsAdmin@localhost  : 100.00% (1) of query, 0.24% (1) of all users",
                "querySample": "select sleep(5);"
            }
        ],
        "totalRecord": 2
    }

Abnormal Response

For details, see Abnormal Request Results.