Help Center/ Relational Database Service/ API Reference/ API v3 (Recommended)/ Log Information Queries/ Obtaining Slow Query Log Statistics (RDS for MySQL)
Updated on 2024-03-28 GMT+08:00

Obtaining Slow Query Log Statistics (RDS for MySQL)

Function

This API is used to query and collect statistics on slow query logs based on service requirements.

  • Before calling an API, you need to understand the API in Authentication.

Constraints

This API is supported for MySQL only.

URI

  • URI format

    GET /v3/{project_id}/instances/{instance_id}/slowlog/statistics?cur_page={cur_page}&per_page={per_page}&type={type}&start_date={start_date}&end_date={end_date}

  • Parameter description
    Table 1 Parameter description

    Name

    Mandatory

    Description

    project_id

    Yes

    Specifies the project ID of a tenant in a region.

    For details about how to obtain the project ID, see Obtaining a Project ID.

    instance_id

    Yes

    Specifies the ID of the DB instance to be queried.

    cur_page

    Yes

    Specifies the page offset (the current page number, such as 1, 2, 3, or 4.)

    per_page

    Yes

    Specifies the number of records on each page. The value ranges from 0 to 100.

    start_date

    Yes

    Specifies the start date in the "yyyy-mm-ddThh:mm:ssZ" format.

    T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset. For example, in the Beijing time zone, the time zone offset is shown as +0800.

    end_date

    Yes

    Specifies the end time in the "yyyy-mm-ddThh:mm:ssZ" format.

    T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset. For example, in the Beijing time zone, the time zone offset is shown as +0800.

    type

    Yes

    Specifies the statement type. If it is left blank, all statement types are queried. Valid value:

    • INSERT
    • UPDATE
    • SELECT
    • DELETE
    • CREATE
    • ALL

Request

  • Request parameters

    None

Response

  • Normal response
    Table 2 Description

    Name

    Type

    Description

    pageNumber

    Integer

    Indicates the current page number.

    pageRecord

    Integer

    Indicates the number of records on each page.

    slowLogList

    List

    See Table 3.

    totalRecord

    Integer

    Indicates the total number of records.

    startTime

    Long

    Indicates the start time.

    endTime

    Long

    Indicates the end time.

    Table 3 slowLogList field data structure description

    Name

    Type

    Description

    count

    String

    Indicates the number of executions.

    time

    String

    Indicates the execution time.

    lockTime

    String

    Indicates the lock wait time.

    rowsSent

    Long

    Indicates the number of sent rows.

    rowsExamined

    Long

    Indicates the 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.

    type

    String

    Indicates the statement type.

    clientIP

    String

    Indicates the IP address.

  • Example normal response
    {
    	"pageNumber": 1,
    	"pageRecord": 10,
    	"slowLogList": [],
    	"totalRecord": 0,
            "startTime": null,
            "endTime":null
    }
  • Abnormal response

    For details, see Abnormal Request Results.

Status Code

Error Code

For details, see Error Codes.