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列有重复索引,并给出删除索引的语句。

发布了274 篇原创文章 · 获赞 65 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/qianglei6077/article/details/98735736