首页/数据/SQL 速查/sys schema 巡检视图
本包目录(311 条)
查询基础33 条连接与子查询40 条聚合与窗口函数54 条函数速查60 条变更与事务52 条
性能与执行计划72 条

sys schema 巡检视图

sys 把 performance_schema 原始数据整理成可读结果:全表扫描语句、表级 IO、未使用索引都有对应视图。

SQL 速查数据更新于 2026-10-12

示例

示例
-- 走全表扫描的语句
SELECT query, exec_count, total_latency, rows_examined
FROM sys.statements_with_full_table_scans
ORDER BY exec_count DESC
LIMIT 10;

-- 表级读写与 IO 延迟
SELECT table_schema, table_name, rows_fetched, io_read_latency
FROM sys.schema_table_statistics
ORDER BY io_read_latency DESC
LIMIT 10;

-- 实例启动以来未被使用的索引
SELECT * FROM sys.schema_unused_indexes;
数据来源performance_schema 汇总表;实例重启后统计清零
schema_unused_indexes按索引使用统计列出未命中索引;主键不参与统计
前提相关 instrument 与 consumer 处于开启状态(默认配置通常可用)

易错点

  • 照着 schema_unused_indexes 直接删索引:统计自启动以来,报表类低频索引可能只是近期没被用到
  • 统计全为 0 就认为无负载:先确认对应 instrument 与 consumer 已开启,否则是监控没有采到而不是没有使用

数据来源与参考

  • MySQL 8.0 Reference Manual §30 MySQL sys Schema
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌