Help Center> Relational Database Service> API Reference> API v3 (Recommended)> Log Information Queries> Obtaining Slow Query Log Statistics (RDS for MySQL)
Updated on 2024-06-07 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}&sort={sort}

  • Parameter description
    Table 1 Parameter description

    Name

    Mandatory

    Description

    project_id

    Yes

    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

    sort

    No

    Specifies the sorting mode.

    • executeTime: indicates sorting slow query logs by execution time in descending order.
    • If this parameter is left empty or set to other values, the slow query logs are sorted by executions in descending order.

Request

  • Request parameters

    None

  • URI example

    GET https://{endpoint}/v3/0483b6b16e954cb88930a360d2c4e663/instances/cee5265e1e5845649e354841234567dfin01/slowlog/statistics?cur_page=1&per_page=2&type=INSERT&start_date=2020-02-06T10:41:14+0800&end_date=2020-02-07T10:41:14+0800&sort=executeTime

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.