tencent cloud

Feedback

DescribeSlowQueryList

Last updated: 2024-06-17 14:26:01

    1. API Description

    Domain name for API request: postgres.tencentcloudapi.com.

    This API is used to get the slow queries during the specified period of time.

    A maximum of 100 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: DescribeSlowQueryList.
    Version Yes String Common Params. The value used for this API: 2017-03-12.
    Region No String Common Params. This parameter is not required for this API.
    DBInstanceId Yes String Instance ID.
    StartTime Yes String Query start time, in the format of 2018-01-01 00:00:00. The log is retained for seven days by default, so the start time must fall within the retention period.
    EndTime Yes String Query end time, in the format of 2018-01-01 00:00:00.
    DatabaseName No String Database name.
    OrderByType No String Sorting method, including ascending: asc and descending: desc. The default value is desc.
    OrderBy No String Sorting field, with a value range of [SessionStartTime, Duration]. The default value is SessionStartTime.
    Limit No Integer Number of results returned per page, with a value range of 1-100. The default value is 50.
    Offset No Integer Data offset, which starts from 0. The default value is 0.

    3. Output Parameters

    Parameter Name Type Description
    TotalCount Integer Number of slow logs found, with a maximum of 10,000 entries.
    DurationAnalysis Array of DurationAnalysis Segmented analysis results of the time consumption of the slow logs found.
    Note: This field may return null, indicating that no valid values can be obtained.
    RawSlowQueryList Array of RawSlowQuery Collection of detailed information on slow logs found.
    Note: This field may return null, indicating that no valid values can be obtained.
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Example of Querying the Slow Log List

    This example shows you how to obtain the slow logs of an instance within a specified time range.

    Input Example

    POST / HTTP/1.1
    Host: postgres.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: DescribeSlowQueryList
    <Common request parameters>
    
    {
        "StartTime": "7/22/2021 10:00:07 AM",
        "EndTime": "7/27/2021 20:15:07",
        "Limit": 10,
        "Offset": 0,
        "DBInstanceId": "postgres-nbvqjlhf"
    }
    

    Output Example

    {
        "Response": {
            "DurationAnalysis": [
                {
                    "Count": 0,
                    "TimeSegment": "10-20s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "40-50s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "50s-"
                },
                {
                    "Count": 0,
                    "TimeSegment": "5-6s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "6-7s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "2-3s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "20-30s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "3-4s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "4-5s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "7-8s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "8-9s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "9-10s"
                },
                {
                    "Count": 0,
                    "TimeSegment": "30-40s"
                },
                {
                    "Count": 6,
                    "TimeSegment": "1-2s"
                }
            ],
            "RawSlowQueryList": [
                {
                    "ClientAddr": "[local]",
                    "DatabaseName": "postgres",
                    "Duration": 101.013,
                    "RawQuery": "select 1 from information_schema.tables where table_schema = 'pg_catalog' and table_name = 'pg_file_settings'",
                    "SessionStartTime": "2021-07-27 03:12:01 CST",
                    "UserName": "postgres"
                },
                {
                    "ClientAddr": "::1:34301",
                    "DatabaseName": "postgres",
                    "Duration": 155.283,
                    "RawQuery": "select count(*)::text as value from pg_stat_activity where now()-backend_start < '5  second';",
                    "SessionStartTime": "2021-07-25 02:25:09 CST",
                    "UserName": "postgres"
                },
                {
                    "ClientAddr": "::1:34295",
                    "DatabaseName": "postgres",
                    "Duration": 168.119,
                    "RawQuery": "select count(*)::text as value from pg_stat_activity where state='active';",
                    "SessionStartTime": "2021-07-25 02:25:09 CST",
                    "UserName": "postgres"
                },
                {
                    "ClientAddr": "::1:34296",
                    "DatabaseName": "postgres",
                    "Duration": 168.757,
                    "RawQuery": "select count(*)::text as value from pg_stat_activity where wait_event_type is not null",
                    "SessionStartTime": "2021-07-25 02:25:09 CST",
                    "UserName": "postgres"
                },
                {
                    "ClientAddr": "::1:34298",
                    "DatabaseName": "postgres",
                    "Duration": 165.119,
                    "RawQuery": "select application_name,COALESCE(pg_catalog.pg_wal_lsn_diff(sent_lsn, replay_lsn),0) from pg_stat_replication;",
                    "SessionStartTime": "2021-07-25 02:25:09 CST",
                    "UserName": "postgres"
                },
                {
                    "ClientAddr": "::1:34297",
                    "DatabaseName": "postgres",
                    "Duration": 104.795,
                    "RawQuery": "select count(*)::text as value from pg_stat_activity where state='idle';",
                    "SessionStartTime": "2021-07-25 02:25:09 CST",
                    "UserName": "postgres"
                }
            ],
            "RequestId": "221334ddcf",
            "TotalCount": 6
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation.CamSigAndAuthError Authentication failed. Please try again later. If the problem persists, please contact customer service.
    FailedOperation.DatabaseAffectedError Data operation failed. Please contact customer service.
    FailedOperation.FailedOperationError Operation failed. Please try again later.
    InternalError.InternalHttpServerError An exception occurred while executing the request.
    InvalidParameterValue.InvalidParameterValueError Incorrect parameter value
    InvalidParameterValue.ParameterValueExceedError The maximum value of the parameter has been reached.
    OperationDenied.CamDeniedError This operation cannot be performed.
    OperationDenied.InstanceAccessDeniedError You do not have the permission to operate this resource.
    ResourceNotFound.InstanceNotFoundError The instance does not exist.