Percona-Toolkit系列(7) --- pt-duplicate-key-checker

pt-duplicate-key-checker

pt-duplicate-key-checker:官方地址

說明

用途:查找MySQL表中的重複、冗餘索引和外鍵。

語法:

pt-duplicate-key-checker [OPTIONS] [DSN]

pt-duplicate-key-checker檢查MySQL表中的重複或冗餘索引和外鍵。連接選項從MySQL選項文件中讀取。

具體示例

檢查數據庫:test中表:cms_areas

[root@BigData ~]# pt-duplicate-key-checker h=192.168.20.66,p=123,P=3306,D=test --tables=cms_areas
# ########################################################################
# test.cms_areas
# ########################################################################

# Uniqueness of id_pk ignored because PRIMARY is a duplicate constraint
# id_pk is a duplicate of PRIMARY
# Key definitions:
#   UNIQUE KEY `id_pk` (`id`) USING BTREE
#   PRIMARY KEY (`id`) USING BTREE,
# Column types:
#         `id` int(11) unsigned not null
# To remove this duplicate index, execute:
ALTER TABLE `test`.`cms_areas` DROP INDEX `id_pk`;

# ########################################################################
# Summary of indexes
# ########################################################################

# Size Duplicate Indexes   4
# Total Duplicate Indexes  1
# Total Indexes            3

可以看出ID列有重複索引,並給出刪除索引的語句。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章