pt-duplicate-key-checker 與 mysql information_schema檢查冗余索引

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`
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容