pt-duplicate-key-checker
用法:
pt-duplicate-key-checker A=utf8, F=/etc/my.cnf, h=localhost, u=root, P=3306 --ask-pass --databases=voole_vrm --tables=v3a_resumelist
执行结果分析:
# idex_hid is a left-prefix of hid_oemid_mid 说明冗余索引的类型
# Key definitions: # 以下为两个索引的定义
# KEY `idex_hid` (`hid`),
# KEY `hid_oemid_mid` (`hid`,`oemid`,`mid`) USING BTREE,
# Column types: # 索引对应列的定义
# `hid` varchar(40) default '' comment '终端硬件id'
# `oemid` int(11) default '0' comment '终端oemid'
# `mid` int(11) default '0' comment '影片编号'
# To remove this duplicate index, execute: # 以下为去掉索引要执行的sql
ALTER TABLE `mobileservice_b2c9`.`v3a_resumelist` DROP INDEX `idex_hid`;
说明:
工具很好用,检错冗余索引,在mysql 5.7 中有对应的系统表来查询冗余索引
mysql information_schema
select * from sys.schema_redundant_indexes\G
table_schema: voole_ad
table_name: new_ad_movieinfo
redundant_index_name: amid
redundant_index_columns: amid
redundant_index_non_unique: 1
dominant_index_name: PRIMARY
dominant_index_columns: amid
dominant_index_non_unique: 0
subpart_exists: 0
sql_drop_index: ALTER TABLE `voole_ad`.`new_ad_movieinfo` DROP INDEX `amid`