您的位置:首页 > 数据库 > SQL

MySQL索引的维护与优化——查找重复及冗余索引

2017-09-30 00:00 232 查看
方法一:通过MySQL的information_schema数据库 查找重复与冗余索引

SELECT a.table_schema AS '数据库', a.table_name AS '表名', a.index_name AS '索引1', b.index_name AS '索引2', a.column_name AS '重复列名'
FROM information_schema.statistics a
JOIN statistics b ON a.table_schema = b.table_schema
AND a.table_name = b.table_name
AND a.seq_in_index = b.seq_in_index
AND a.column_name = b.column_name
WHERE a.seq_in_index = 1
AND a.index_name != b.index_name


方法二:通过工具

用pt-duplicate-key-checker 工具检查重复及冗余索引
使用方法 pt-duplicate-key-checker -hxxx -uxxx -pxxx


查找重复与冗余索引

参考慕课网:http://www.imooc.com/video/3998
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: