Obtaining Slow Query Log Statistics

Function

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

Constraints

This API is supported for MySQL only.

URI

  • URI format

    GET https://{Endpoint}/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.

    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.

    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

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.

    Table 3 slow_log_list 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.

    This parameter is not present in the response for PostgreSQL DB engine.

    rowsSent

    Long

    Indicates the number of sent rows.

    This parameter is not present in the response for PostgreSQL DB engine.

    rowsExamined

    Long

    Indicates the number of scanned rows.

    This parameter is not present in the response for PostgreSQL DB engine.

    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.