• 06. pt-duplicate-key-checker



    | t01 | CREATE TABLE `t01` (
    `pkid` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `name` varchar(50) NOT NULL,
    `code` int(11) NOT NULL,
    `ctime` datetime DEFAULT CURRENT_TIMESTAMP,
    `utime` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`pkid`),
    KEY `idx_name` (`name`),
    KEY `idx_code` (`code`),
    KEY `idx_name_code` (`name`,`code`)
    ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 |

    vim duplicate_key.cnf

    host=192.168.100.101
    port=3306
    user=admin
    password=admin
    databases=db01
    tables=t01,pt_deadlocks
    clustered
    all-structs


    pt-duplicate-key-checker --config duplicate_key.cnf


    # ########################################################################
    # db01.t01
    # ########################################################################

    # idx_name is a left-prefix of idx_name_code
    # Key definitions:
    # KEY `idx_name` (`name`)
    # KEY `idx_name_code` (`name`,`code`),
    # Column types:
    # `name` varchar(50) not null
    # `code` int(11) not null
    # To remove this duplicate index, execute:
    ALTER TABLE `db01`.`t01` DROP INDEX `idx_name`;

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

    # Size Duplicate Indexes 1010
    # Total Duplicate Indexes 1
    # Total Indexes 5


    pt-duplicate-key-checker h=192.168.100.101,P=3306,u=admin,p=admin -d db01 -t t01,pt_deadlocks


    # ########################################################################
    # db01.t01
    # ########################################################################

    # idx_name is a left-prefix of idx_name_code
    # Key definitions:
    # KEY `idx_name` (`name`),
    # KEY `idx_name_code` (`name`,`code`)
    # Column types:
    # `name` varchar(50) not null
    # `code` int(11) not null
    # To remove this duplicate index, execute:
    ALTER TABLE `db01`.`t01` DROP INDEX `idx_name`;

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

    # Size Duplicate Indexes 1010
    # Total Duplicate Indexes 1
    # Total Indexes 5

    pt-duplicate-key-checker h=192.168.100.101,P=3306,u=admin,p=admin -d db01

    # ########################################################################
    # db01.t01
    # ########################################################################

    # idx_name is a left-prefix of idx_name_code
    # Key definitions:
    # KEY `idx_name` (`name`),
    # KEY `idx_name_code` (`name`,`code`)
    # Column types:
    # `name` varchar(50) not null
    # `code` int(11) not null
    # To remove this duplicate index, execute:
    ALTER TABLE `db01`.`t01` DROP INDEX `idx_name`;

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

    # Size Duplicate Indexes 1010
    # Total Duplicate Indexes 1
    # Total Indexes 5


    [root@server01 ~]# mysql -e 'alter table db01.t01 drop index idx_name'


    [root@server01 ~]# pt-duplicate-key-checker h=192.168.100.101,P=3306,u=admin,p=admin -d db01 -t t01,pt_deadlocks

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

    # Total Indexes 4

    wechat: nick753159 qq: 417966852 email: nzq42@qq.com base: shanghai
  • 相关阅读:
    【Python】版本自动控制/在上一次版本中自动生成本次的版本号
    【Python】获取当前国内时间(适用于服务器部署在国外的)
    【Python】url编码/解码/转义
    mysql 优化详解
    shiro-redis整合
    springboot 整合redis ,jedis
    maven的pom配置详解
    SpringMVC集成LogBack,相关配置
    客户端连接caching-sha2-password 报错问题
    (转)navicat premium 12 破解版,注册机激活
  • 原文地址:https://www.cnblogs.com/cyberbit/p/pt-duplicate-key-checker.html
Copyright © 2020-2023  润新知