Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slow-query: add Warnings field to slow log and the slow query table #12638

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions identify-slow-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Slow Query 基础信息:
* `Backoff_total`:表示这个语句在执行过程中所有 backoff 花费的时间。
* `Write_sql_response_total`:表示这个语句把结果发送回客户端花费的时间。
* `Result_rows`:表示这个语句查询结果的行数。
* `Warnings`:表示这个语句执行过程中产生的警告,采用 JSON 格式。通常和 [`SHOW WARNINGS`](/sql-statements/sql-statement-show-warnings.md) 语句的输出结果一致,但是可能会包含 [`SHOW WARNINGS`](/sql-statements/sql-statement-show-warnings.md) 中没有的警告,因而可以提供更多诊断信息。这类警告将被标记为 `IsExtra: true`。
* `IsExplicitTxn`:表示这个语句是否在一个明确声明的事务中。如果是 `false`,表示这个语句的事务是 `autocommit=1`,即语句执行完成后就自动提交的事务。

和事务执行相关的字段:
Expand Down
6 changes: 4 additions & 2 deletions information-schema/information-schema-slow-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ DESC slow_query;
| Backoff_total | double | YES | | NULL | |
| Write_sql_response_total | double | YES | | NULL | |
| Result_rows | bigint(22) | YES | | NULL | |
| Warnings | longtext | YES | | NULL | |
| Backoff_Detail | varchar(4096) | YES | | NULL | |
| Prepared | tinyint(1) | YES | | NULL | |
| Succ | tinyint(1) | YES | | NULL | |
Expand All @@ -92,7 +93,7 @@ DESC slow_query;
| Prev_stmt | longtext | YES | | NULL | |
| Query | longtext | YES | | NULL | |
+-------------------------------+---------------------+------+------+---------+-------+
73 rows in set (0.000 sec)
74 rows in set (0.001 sec)
```

## CLUSTER_SLOW_QUERY table
Expand Down Expand Up @@ -170,6 +171,7 @@ desc cluster_slow_query;
| Backoff_total | double | YES | | NULL | |
| Write_sql_response_total | double | YES | | NULL | |
| Result_rows | bigint(22) | YES | | NULL | |
| Warnings | longtext | YES | | NULL | |
| Backoff_Detail | varchar(4096) | YES | | NULL | |
| Prepared | tinyint(1) | YES | | NULL | |
| Succ | tinyint(1) | YES | | NULL | |
Expand All @@ -184,7 +186,7 @@ desc cluster_slow_query;
| Prev_stmt | longtext | YES | | NULL | |
| Query | longtext | YES | | NULL | |
+-------------------------------+---------------------+------+------+---------+-------+
74 rows in set (0.000 sec)
75 rows in set (0.001 sec)
```

查询集群系统表时,TiDB 也会将相关计算下推给其他节点执行,而不是把所有节点的数据都取回来,可以查看执行计划,如下:
Expand Down