更新时间:2025-08-28 GMT+08:00
分享

查询实例的TOP慢SQL列表

功能介绍

查询实例的TOP慢SQL列表。

调试

您可以在API Explorer中调试该接口。

URI

GET /v3/{project_id}/instances/{instance_id}/top-slow-log

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释

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

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

约束限制:

不涉及。

取值范围:

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

默认取值:

不涉及。

instance_id

String

参数解释:

实例ID。标识实例的唯一标识。

约束限制:

不涉及。

取值范围:

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

默认取值:

不涉及。

表2 Query参数

参数

是否必选

参数类型

描述

num

Integer

参数解释:

TOP数量。

约束限制:

不涉及。

取值范围:

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

默认取值:

不涉及。

start_at

Long

参数解释:

开始时间。

约束限制:

Unix timestamp,单位:毫秒。

取值范围:

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

默认取值:

不涉及。

end_at

Long

参数解释:

结束时间。

约束限制:

Unix timestamp,单位:毫秒。

取值范围:

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

默认取值:

不涉及。

请求参数

无。

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

top_execute_slow_logs

Array of 表4 top_execute_slow_logs objects

参数解释:

执行次数列表。

取值范围:

不涉及。

top_avg_query_time_slow_logs

Array of 表5 top_avg_query_time_slow_logs objects

参数解释:

平均执行时间列表。

取值范围:

不涉及。

top_max_query_time_slow_logs

Array of 表6 top_max_query_time_slow_logs objects

参数解释:

最大执行时间列表。

取值范围:

不涉及。

rows_examined_exceeding

Array of 表7 rows_examined_exceeding objects

参数解释:

扫描返回比列表。

取值范围:

不涉及。

表4 top_execute_slow_logs

参数

参数类型

描述

template_id

String

参数解释:

SQL模板ID。

取值范围:

不涉及。

template

String

参数解释:

SQL模板。

取值范围:

不涉及。

databases

Array of strings

参数解释:

数据库名称。

取值范围:

不涉及。

times

Long

参数解释:

执行次数。

取值范围:

不涉及。

avg_query_time

Double

参数解释:

平均执行时间。

取值范围:

不涉及。

max_query_time

Double

参数解释:

最大执行时间。

取值范围:

不涉及。

avg_rows_examined

Double

参数解释:

平均扫描行数。

取值范围:

不涉及。

sum_rows_examined

Double

参数解释:

扫描行数总和。

取值范围:

不涉及。

avg_rows_sent

Double

参数解释:

平均返回行数。

取值范围:

不涉及。

表5 top_avg_query_time_slow_logs

参数

参数类型

描述

template_id

String

参数解释:

SQL模板ID。

取值范围:

不涉及。

template

String

参数解释:

SQL模板。

取值范围:

不涉及。

databases

Array of strings

参数解释:

数据库名称。

取值范围:

不涉及。

times

Long

参数解释:

执行次数。

取值范围:

不涉及。

avg_query_time

Double

参数解释:

平均执行时间。

取值范围:

不涉及。

max_query_time

Double

参数解释:

最大执行时间。

取值范围:

不涉及。

avg_rows_examined

Double

参数解释:

平均扫描行数。

取值范围:

不涉及。

sum_rows_examined

Double

参数解释:

扫描行数总和。

取值范围:

不涉及。

avg_rows_sent

Double

参数解释:

平均返回行数。

取值范围:

不涉及。

表6 top_max_query_time_slow_logs

参数

参数类型

描述

template_id

String

参数解释:

SQL模板ID。

取值范围:

不涉及。

template

String

参数解释:

SQL模板。

取值范围:

不涉及。

databases

Array of strings

参数解释:

数据库名称。

取值范围:

不涉及。

times

Long

参数解释:

执行次数。

取值范围:

不涉及。

avg_query_time

Double

参数解释:

平均执行时间。

取值范围:

不涉及。

max_query_time

Double

参数解释:

最大执行时间。

取值范围:

不涉及。

avg_rows_examined

Double

参数解释:

平均扫描行数。

取值范围:

不涉及。

sum_rows_examined

Double

参数解释:

扫描行数总和。

取值范围:

不涉及。

avg_rows_sent

Double

参数解释:

平均返回行数。

取值范围:

不涉及。

表7 rows_examined_exceeding

参数

参数类型

描述

template_id

String

参数解释:

SQL模板ID。

取值范围:

不涉及。

template

String

参数解释:

SQL模板。

取值范围:

不涉及。

databases

Array of strings

参数解释:

数据库名称。

取值范围:

不涉及。

times

Long

参数解释:

执行次数。

取值范围:

不涉及。

avg_query_time

Double

参数解释:

平均执行时间。

取值范围:

不涉及。

max_query_time

Double

参数解释:

最大执行时间。

取值范围:

不涉及。

avg_rows_examined

Double

参数解释:

平均扫描行数。

取值范围:

不涉及。

sum_rows_examined

Double

参数解释:

扫描行数总和。

取值范围:

不涉及。

avg_rows_sent

Double

参数解释:

平均返回行数。

取值范围:

不涉及。

请求示例

"GET https://das.cn-north-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/instances/5c59fa7d6f09456b947f32922f9aeda1in01/top-slow-log?num=10&start_at=1736402167045&end_at=1736403967045"

响应示例

状态码: 200

Success.

{
  "top_execute_slow_logs": [
    {
      "template_id": "1D7880577913B207",
      "template": "SELECT sleep(?);",
      "databases": [],
      "times": 21,
      "avg_query_time": 6.429124786740258,
      "max_query_time": 10,
      "avg_rows_examined": 0,
      "sum_rows_examined": 0,
      "avg_rows_sent": 1
    }
  ],
  "top_avg_query_time_slow_logs": [
    {
      "template_id": "1D7880577913B207",
      "template": "SELECT sleep(?);",
      "databases": [],
      "times": 21,
      "avg_query_time": 6.429124786740258,
      "max_query_time": 10,
      "avg_rows_examined": 0,
      "sum_rows_examined": 0,
      "avg_rows_sent": 1
    }
  ],
  "top_max_query_time_slow_logs": [
    {
      "template_id": "1D7880577913B207",
      "template": "SELECT sleep(?);",
      "databases": [],
      "times": 21,
      "avg_query_time": 6.429124786740258,
      "max_query_time": 10,
      "avg_rows_examined": 0,
      "sum_rows_examined": 0,
      "avg_rows_sent": 1
    }
  ],
  "rows_examined_exceeding": []
}

状态码

状态码

描述

200

Success.

400

BadRequest.

500

InternalServerError.

错误码

请参见错误码

相关文档