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
執(zhí)行結(jié)果分析:
# 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: # 索引對應(yīng)列的定義
# `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: # 以下為去掉索引要執(zhí)行的sql
ALTER TABLE `mobileservice_b2c9`.`v3a_resumelist` DROP INDEX `idex_hid`;
說明:
工具很好用,檢錯冗余索引夺鲜,在mysql 5.7 中有對應(yīng)的系統(tǒng)表來查詢?nèi)哂嗨饕?
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`