tencent cloud

文档反馈

DescribeSlowQueryAnalysis

最后更新时间:2024-06-17 14:26:02

    1. API Description

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

    This API is used to count and analyze slow query statements during the specified period of time and return aggregated statistical analysis results which are classified by statement with abstract parameter values.

    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: DescribeSlowQueryAnalysis.
    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
    OrderBy No String Sorting field, with valid values [CallNum, CostTime, AvgCostTime]. The default value is CallNum.
    OrderByType No String Sorting method, including ascending: asc and descending: desc. The default value is desc.
    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 Total number found, with a maximum of 10,000 entries.
    Detail Detail Collection of detailed information on slow SQL statistical analysis found.
    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 Instance of Interface for Slow Log Query Statistical Analysis

    This example shows you how to obtain the slow log query statistical analysis results 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: DescribeSlowQueryAnalysis
    <Common request parameters>
    
    {
        "StartTime": "2021-06-17 20:00:07",
        "EndTime": "2021-06-17 20:15:07",
        "Limit": 10,
        "Offset": 0,
        "DBInstanceId": "postgres-nbvqjlhf"
    }
    

    Output Example

    {
        "Response": {
            "Detail": {
                "AnalysisItems": [
                    {
                        "AvgCostTime": 101.01300048828125,
                        "ClientAddr": "",
                        "CostPercent": 11.703700311890035,
                        "CostTime": 101.01300048828125,
                        "DatabaseName": "postgres",
                        "FirstTime": "2021-07-27 03:12:01",
                        "LastTime": "2021-07-27 03:12:01",
                        "MaxCostTime": 101.01300048828125,
                        "MinCostTime": 101.01300048828125,
                        "NormalQuery": "select $1 from information_schema.tables where table_schema = $2 and table_name = $3",
                        "UserName": "postgres"
                    }
                ],
                "TotalCallNum": 6,
                "TotalTime": 863.0860137939453
            },
            "RequestId": "221334ddc4f",
            "TotalCount": 5
        }
    }
    

    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.ESQueryError Failed to query ES. Please try again later. If the problem persists, please contact customer service.
    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.
    ResourceNotFound.InstanceNotFoundError The instance does not exist.