-- 查询冗余索引(比如对于 name 字段创建了一个单列索引,有创建了一个 name 和 code 的联合索引)select*from sys.schema_redundant_indexes;
-- 查询未使用过的索引select*from sys.schema_unused_indexes;
-- 查询索引的使用情况select index_name,rows_selected,rows_inserted,rows_updated,rows_deleted
from sys.schema_index_statistics where table_schema='dbname' ;
表相关
-- 查询表的访问量select table_schema,table_name,sum(io_read_requests+io_write_requests) as io from
sys.schema_table_statistics groupby table_schema,table_name orderby io desc;
-- 查询占用bufferpool较多的表select object_schema,object_name,allocated,data
from sys.innodb_buffer_stats_by_table orderby allocated limit 10;
-- 查看表的全表扫描情况select*from sys.statements_with_full_table_scans where db='dbname';
语句相关
-- 监控SQL执行的频率select db,exec_count,query from sys.statement_analysis
orderby exec_count desc;
-- 监控使用了排序的SQLselect db,exec_count,first_seen,last_seen,query
from sys.statements_with_sorting limit 1;
-- 监控使用了临时表或者磁盘临时表的SQLselect db,exec_count,tmp_tables,tmp_disk_tables,query
from sys.statement_analysis where tmp_tables>0or tmp_disk_tables >0orderby (tmp_tables+tmp_disk_tables) desc
I/O 相关
-- 查看消耗磁盘IO的文件select file,avg_read,avg_write,avg_read+avg_write as avg_io
from sys.io_global_by_file_by_bytes orderby avg_read limit 10;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具