文档首页/ 数据管理服务 DAS/ API参考/ API/ 云DBA/ TOP慢SQL列表 - InsGetTopSlowLog
更新时间:2026-09-20 GMT+08:00
分享

TOP慢SQL列表 - InsGetTopSlowLog

功能介绍

TOP慢SQL列表。

授权信息

账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。

  • 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
  • 如果使用身份策略授权,需具备如下身份策略权限。

    授权项

    访问级别

    资源类型(*为必须)

    条件键

    别名

    依赖的授权项

    das::showCloudDBAInfo

    read

    instance

    -

    -

    -

URI

GET /v3/{project_id}/tenant-panel/{instance_id}/get-top-slow-log

表1 路径参数

参数

是否必选

参数类型

描述

project_id

是

String

参数解释:

租户在某一Region下的项目ID。

获取方法请参见获取项目ID。

约束限制:

不涉及。

取值范围:

只能由英文字母、数字组成,且长度为32个字符。

默认取值:

不涉及。

表2 Query参数

参数

是否必选

参数类型

描述

num

是

Integer

参数解释:

TOP数量。

约束限制:

不涉及

取值范围:

[0, 2^31-1],实际取决于查询。

默认取值:

不涉及。

start_at

是

Long

参数解释:

开始时间。

约束限制:

Unix timestamp,单位:毫秒。

取值范围:

[0, 2^63-1],实际取决于查询。

默认取值:

不涉及。

end_at

是

Long

参数解释:

结束时间。

约束限制:

Unix timestamp,单位:毫秒。

取值范围:

[0, 2^63-1],实际取决于查询。

默认取值:

不涉及。

请求参数

无。

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

collect_slow_log

Boolean

参数解释:

采集慢SQL开关。

取值范围:

不涉及。

top_execute_slow_logs

Array of 表4 top_slow_log_list objects

参数解释:

按执行次数排序的慢SQL列表。

top_avg_query_time_slow_logs

Array of 表4 top_slow_log_list objects

参数解释:

按平均执行时间排序的慢SQL列表。

top_max_query_time_slow_logs

Array of 表4 top_slow_log_list objects

参数解释:

按最大执行时间排序的慢SQL列表。

rows_examined_exceeding

Array of 表4 top_slow_log_list objects

参数解释:

按扫描返回比排序的慢SQL列表。

表4 top_slow_log

参数

参数类型

描述

template_id

String

参数解释:

模板ID。

取值范围:

不涉及。

template

String

参数解释:

SQL模板。

取值范围:

不涉及。

databases

Array of String

参数解释:

数据库名。

times

Long

参数解释:

执行次数。

取值范围:

[0, 2^31-1]

avg_query_time

Double

参数解释:

平均执行时间。

取值范围:

不涉及。

max_query_time

Double

参数解释:

最大执行时间。

取值范围:

不涉及。

avg_rows_examined

Double

参数解释:

平均扫描行。

取值范围:

不涉及。

max_rows_examined

Double

参数解释:

最大扫描行。

取值范围:

不涉及。

sum_rows_examined

Double

参数解释:

总扫描行。

取值范围:

不涉及。

avg_rows_sent

Double

参数解释:

平均返回行。

取值范围:

不涉及。

max_rows_sent

Double

参数解释:

最大返回行。

取值范围:

不涉及。

请求示例

GET https://das.cn-north-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/tenant-panel/5c59fa7d6f09456b947f32922f9aeda1in01/get-top-slow-log?num=10&start_at=1764144205476&end_at=1764146005476

响应示例

状态码: 200

Success.

{
    "collect_slow_log": true,
    "top_execute_slow_logs": [
        {
            "template_id": "AAD913807ECE9C66",
            "template": "SELECT sleep(?)",
            "databases": [],
            "times": 6,
            "avg_query_time": 10.0,
            "max_query_time": 10.0,
            "avg_rows_examined": 0.0,
            "sum_rows_examined": 0.0,
            "avg_rows_sent": 1.0
        }
    ],
    "top_avg_query_time_slow_logs": [
        {
            "template_id": "AAD913807ECE9C66",
            "template": "SELECT sleep(?)",
            "databases": [],
            "times": 6,
            "avg_query_time": 10.0,
            "max_query_time": 10.0,
            "avg_rows_examined": 0.0,
            "sum_rows_examined": 0.0,
            "avg_rows_sent": 1.0
        }
    ],
    "top_max_query_time_slow_logs": [
        {
            "template_id": "AAD913807ECE9C66",
            "template": "SELECT sleep(?)",
            "databases": [],
            "times": 6,
            "avg_query_time": 10.0,
            "max_query_time": 10.0,
            "avg_rows_examined": 0.0,
            "sum_rows_examined": 0.0,
            "avg_rows_sent": 1.0
        }
    ],
    "rows_examined_exceeding": []
}

状态码

状态码

描述

200

Success.

400

Client error.

500

Server error.

错误码

请参见错误码。

相关文档