- 关于 TiDB
- 快速上手
- 部署集群
- 数据迁移
- 数据迁移概述
- 从 MySQL 迁移至 TiDB
- 从 CSV 文件迁移至 TiDB
- 运维操作
- 监控与告警
- 故障诊断
- 性能调优
- 系统调优
- 软件调优
- SQL 性能调优
- 教程
- TiDB 生态工具
- TiDB 生态工具功能概览
- TiDB 生态工具适用场景
- TiDB 工具下载
- Backup & Restore (BR)
- TiDB Binlog
- TiDB Lightning
- TiCDC 简介
- Dumpling 使用文档
- sync-diff-inspector
- Loader 使用文档
- Mydumper 使用文档
- Syncer 使用文档
- TiSpark
- 参考指南
- 架构
- 监控指标
- 安全加固
- 权限
- SQL
- SQL 语言结构和语法
- 属性
- 字面值
- Schema 对象名
- 关键字
- 用户自定义变量
- 表达式语法
- 注释语法
- SQL 语句
- ADD COLUMN
- ADD INDEX
- ADMIN
- ALTER DATABASE
- ALTER INSTANCE
- ALTER TABLE
- ALTER USER
- ANALYZE
- BACKUP
- BEGIN
- CHANGE COLUMN
- CHANGE DRAINER
- CHANGE PUMP
- COMMIT
- CREATE [GLOBAL|SESSION] BINDING
- CREATE DATABASE
- CREATE INDEX
- CREATE ROLE
- CREATE SEQUENCE
- CREATE TABLE LIKE
- CREATE TABLE
- CREATE USER
- CREATE VIEW
- DEALLOCATE
- DELETE
- DESC
- DESCRIBE
- DO
- DROP [GLOBAL|SESSION] BINDING
- DROP COLUMN
- DROP DATABASE
- DROP INDEX
- DROP ROLE
- DROP SEQUENCE
- DROP STATS
- DROP TABLE
- DROP USER
- DROP VIEW
- EXECUTE
- EXPLAIN ANALYZE
- EXPLAIN
- FLASHBACK TABLE
- FLUSH PRIVILEGES
- FLUSH STATUS
- FLUSH TABLES
- GRANT
- GRANT
- INSERT
- KILL [TIDB]
- LOAD STATS
- MODIFY COLUMN
- PREPARE
- RECOVER TABLE
- RENAME INDEX
- RENAME TABLE
- REPLACE
- RESTORE
- REVOKE
- REVOKE
- ROLLBACK
- SELECT
- SET DEFAULT ROLE
- SET [NAMES|CHARACTER SET]
- SET PASSWORD
- SET ROLE
- SET TRANSACTION
- SET [GLOBAL|SESSION]
- SHOW [BACKUPS|RESTORES]
- SHOW ANALYZE STATUS
- SHOW [GLOBAL|SESSION] BINDINGS
- SHOW BUILTINS
- SHOW CHARACTER SET
- SHOW COLLATION
- SHOW [FULL] COLUMNS FROM
- SHOW CONFIG
- SHOW CREATE SEQUENCE
- SHOW CREATE TABLE
- SHOW CREATE USER
- SHOW DATABASES
- SHOW DRAINER STATUS
- SHOW ENGINES
- SHOW ERRORS
- SHOW [FULL] FIELDS FROM
- SHOW GRANTS
- SHOW INDEX [FROM|IN]
- SHOW INDEXES [FROM|IN]
- SHOW KEYS [FROM|IN]
- SHOW MASTER STATUS
- SHOW PLUGINS
- SHOW PRIVILEGES
- SHOW [FULL] PROCESSLIST
- SHOW PROFILES
- SHOW PUMP STATUS
- SHOW SCHEMAS
- SHOW STATS_HEALTHY
- SHOW STATS_HISTOGRAMS
- SHOW STATS_META
- SHOW [GLOBAL|SESSION] STATUS
- SHOW TABLE NEXTROWID
- SHOW TABLE REGIONS
- SHOW TABLE STATUS
- SHOW [FULL] TABLES
- SHOW [GLOBAL|SESSION] VARIABLES
- SHOW WARNINGS
- SHUTDOWN
- Split Region 使用文档
- START TRANSACTION
- TRACE
- TRUNCATE
- UPDATE
- USE
- 数据类型
- 函数与操作符
- 约束
- 生成列
- SQL 模式
- 事务
- 垃圾回收 (GC)
- 视图
- 分区表
- 字符集和排序规则
- 系统表
- TiDB 系统表
- INFORMATION_SCHEMA
- TiDB 简介
- ANALYZE_STATUS
- CHARACTER_SETS
- CLUSTER_CONFIG
- CLUSTER_HARDWARE
- CLUSTER_INFO
- CLUSTER_LOAD
- CLUSTER_LOG
- CLUSTER_SYSTEMINFO
- COLLATIONS
- COLLATIONCHARACTERSET_APPLICABILITY
- COLUMNS
- DDL_JOBS
- ENGINES
- INSPECTION_RESULT
- INSPECTION_RULES
- INSPECTION_SUMMARY
- KEYCOLUMNUSAGE
- METRICS_SUMMARY
- METRICS_TABLES
- PARTITIONS
- PROCESSLIST
- SCHEMATA
- SEQUENCES
- SESSION_VARIABLES
- SLOW_QUERY
- STATISTICS
- TABLES
- TABLE_CONSTRAINTS
- TABLESTORAGESTATS
- TIDBHOTREGIONS
- TIDB_INDEXES
- TIDBSERVERSINFO
- TIFLASH_REPLICA
- TIKVREGIONPEERS
- TIKVREGIONSTATUS
- TIKVSTORESTATUS
- USER_PRIVILEGES
- VIEWS
- Metrics Schema
- SQL 语言结构和语法
- UI
- CLI
- 命令行参数
- 配置文件参数
- 系统变量
- 存储引擎
- TiUP
- 遥测
- 错误码与故障诊断
- TiCDC Open Protocol
- 通过拓扑 label 进行副本调度
- 常见问题解答 (FAQ)
- 术语表
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
SLOW_QUERY
SLOW_QUERY
表中提供了当前节点的慢查询相关的信息,其内容通过解析当前节点的 TiDB 慢查询日志而来,列名和慢日志中的字段名是一一对应。关于如何使用该表调查和改善慢查询,请参考慢查询日志文档。
USE information_schema;
DESC slow_query;
+---------------------------+---------------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------------------+---------------------+------+------+---------+-------+
| Time | timestamp(6) | YES | | NULL | |
| Txn_start_ts | bigint(20) unsigned | YES | | NULL | |
| User | varchar(64) | YES | | NULL | |
| Host | varchar(64) | YES | | NULL | |
| Conn_ID | bigint(20) unsigned | YES | | NULL | |
| Query_time | double | YES | | NULL | |
| Parse_time | double | YES | | NULL | |
| Compile_time | double | YES | | NULL | |
| Rewrite_time | double | YES | | NULL | |
| Preproc_subqueries | bigint(20) unsigned | YES | | NULL | |
| Preproc_subqueries_time | double | YES | | NULL | |
| Optimize_time | double | YES | | NULL | |
| Wait_TS | double | YES | | NULL | |
| Prewrite_time | double | YES | | NULL | |
| Wait_prewrite_binlog_time | double | YES | | NULL | |
| Commit_time | double | YES | | NULL | |
| Get_commit_ts_time | double | YES | | NULL | |
| Commit_backoff_time | double | YES | | NULL | |
| Backoff_types | varchar(64) | YES | | NULL | |
| Resolve_lock_time | double | YES | | NULL | |
| Local_latch_wait_time | double | YES | | NULL | |
| Write_keys | bigint(22) | YES | | NULL | |
| Write_size | bigint(22) | YES | | NULL | |
| Prewrite_region | bigint(22) | YES | | NULL | |
| Txn_retry | bigint(22) | YES | | NULL | |
| Cop_time | double | YES | | NULL | |
| Process_time | double | YES | | NULL | |
| Wait_time | double | YES | | NULL | |
| Backoff_time | double | YES | | NULL | |
| LockKeys_time | double | YES | | NULL | |
| Request_count | bigint(20) unsigned | YES | | NULL | |
| Total_keys | bigint(20) unsigned | YES | | NULL | |
| Process_keys | bigint(20) unsigned | YES | | NULL | |
| DB | varchar(64) | YES | | NULL | |
| Index_names | varchar(100) | YES | | NULL | |
| Is_internal | tinyint(1) | YES | | NULL | |
| Digest | varchar(64) | YES | | NULL | |
| Stats | varchar(512) | YES | | NULL | |
| Cop_proc_avg | double | YES | | NULL | |
| Cop_proc_p90 | double | YES | | NULL | |
| Cop_proc_max | double | YES | | NULL | |
| Cop_proc_addr | varchar(64) | YES | | NULL | |
| Cop_wait_avg | double | YES | | NULL | |
| Cop_wait_p90 | double | YES | | NULL | |
| Cop_wait_max | double | YES | | NULL | |
| Cop_wait_addr | varchar(64) | YES | | NULL | |
| Mem_max | bigint(20) | YES | | NULL | |
| Disk_max | bigint(20) | YES | | NULL | |
| Succ | tinyint(1) | YES | | NULL | |
| Plan_from_cache | tinyint(1) | YES | | NULL | |
| Plan | longblob | YES | | NULL | |
| Plan_digest | varchar(128) | YES | | NULL | |
| Prev_stmt | longblob | YES | | NULL | |
| Query | longblob | YES | | NULL | |
+---------------------------+---------------------+------+------+---------+-------+
54 rows in set (0.00 sec)
CLUSTER_SLOW_QUERY table
CLUSTER_SLOW_QUERY
表中提供了集群所有节点的慢查询相关的信息,其内容通过解析 TiDB 慢查询日志而来,该表使用上和 SLOW_QUERY
表一样。CLUSTER_SLOW_QUERY
表结构上比 SLOW_QUERY
多一列 INSTANCE
,表示该行慢查询信息来自的 TiDB 节点地址。关于如何使用该表调查和改善慢查询,请参考慢查询日志文档。
desc cluster_slow_query;
+---------------------------+---------------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------------------+---------------------+------+------+---------+-------+
| INSTANCE | varchar(64) | YES | | NULL | |
| Time | timestamp(6) | YES | | NULL | |
| Txn_start_ts | bigint(20) unsigned | YES | | NULL | |
| User | varchar(64) | YES | | NULL | |
| Host | varchar(64) | YES | | NULL | |
| Conn_ID | bigint(20) unsigned | YES | | NULL | |
| Query_time | double | YES | | NULL | |
| Parse_time | double | YES | | NULL | |
| Compile_time | double | YES | | NULL | |
| Rewrite_time | double | YES | | NULL | |
| Preproc_subqueries | bigint(20) unsigned | YES | | NULL | |
| Preproc_subqueries_time | double | YES | | NULL | |
| Optimize_time | double | YES | | NULL | |
| Wait_TS | double | YES | | NULL | |
| Prewrite_time | double | YES | | NULL | |
| Wait_prewrite_binlog_time | double | YES | | NULL | |
| Commit_time | double | YES | | NULL | |
| Get_commit_ts_time | double | YES | | NULL | |
| Commit_backoff_time | double | YES | | NULL | |
| Backoff_types | varchar(64) | YES | | NULL | |
| Resolve_lock_time | double | YES | | NULL | |
| Local_latch_wait_time | double | YES | | NULL | |
| Write_keys | bigint(22) | YES | | NULL | |
| Write_size | bigint(22) | YES | | NULL | |
| Prewrite_region | bigint(22) | YES | | NULL | |
| Txn_retry | bigint(22) | YES | | NULL | |
| Cop_time | double | YES | | NULL | |
| Process_time | double | YES | | NULL | |
| Wait_time | double | YES | | NULL | |
| Backoff_time | double | YES | | NULL | |
| LockKeys_time | double | YES | | NULL | |
| Request_count | bigint(20) unsigned | YES | | NULL | |
| Total_keys | bigint(20) unsigned | YES | | NULL | |
| Process_keys | bigint(20) unsigned | YES | | NULL | |
| DB | varchar(64) | YES | | NULL | |
| Index_names | varchar(100) | YES | | NULL | |
| Is_internal | tinyint(1) | YES | | NULL | |
| Digest | varchar(64) | YES | | NULL | |
| Stats | varchar(512) | YES | | NULL | |
| Cop_proc_avg | double | YES | | NULL | |
| Cop_proc_p90 | double | YES | | NULL | |
| Cop_proc_max | double | YES | | NULL | |
| Cop_proc_addr | varchar(64) | YES | | NULL | |
| Cop_wait_avg | double | YES | | NULL | |
| Cop_wait_p90 | double | YES | | NULL | |
| Cop_wait_max | double | YES | | NULL | |
| Cop_wait_addr | varchar(64) | YES | | NULL | |
| Mem_max | bigint(20) | YES | | NULL | |
| Disk_max | bigint(20) | YES | | NULL | |
| Succ | tinyint(1) | YES | | NULL | |
| Plan_from_cache | tinyint(1) | YES | | NULL | |
| Plan | longblob | YES | | NULL | |
| Plan_digest | varchar(128) | YES | | NULL | |
| Prev_stmt | longblob | YES | | NULL | |
| Query | longblob | YES | | NULL | |
+---------------------------+---------------------+------+------+---------+-------+
55 rows in set (0.00 sec)
查询集群系统表时,TiDB 也会将相关计算下推给其他节点执行,而不是把所有节点的数据都取回来,可以查看执行计划,如下:
desc SELECT count(*) FROM cluster_slow_query WHERE user = 'u1';
+--------------------------+----------+-----------+--------------------------+------------------------------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------+----------+-----------+--------------------------+------------------------------------------------------+
| StreamAgg_20 | 1.00 | root | | funcs:count(Column#53)->Column#51 |
| └─TableReader_21 | 1.00 | root | | data:StreamAgg_9 |
| └─StreamAgg_9 | 1.00 | cop[tidb] | | funcs:count(1)->Column#53 |
| └─Selection_19 | 10.00 | cop[tidb] | | eq(information_schema.cluster_slow_query.user, "u1") |
| └─TableFullScan_18 | 10000.00 | cop[tidb] | table:CLUSTER_SLOW_QUERY | keep order:false, stats:pseudo |
+--------------------------+----------+-----------+--------------------------+------------------------------------------------------+
上面执行计划表示,会将 user = u1
条件下推给其他的 (cop
) TiDB 节点执行,也会把聚合算子(即图中的 StreamAgg
算子)下推。
目前由于没有对系统表收集统计信息,所以有时会导致某些聚合算子不能下推,导致执行较慢,用户可以通过手动指定聚合下推的 SQL HINT 来将聚合算子下推,示例如下:
SELECT /*+ AGG_TO_COP() */ count(*) FROM cluster_slow_query GROUP BY user;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论