CREATE TABLE `topic_indicator` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `topic_id` bigint(20) NOT NULL,
  `computation_day` bigint(20) NOT NULL,
  `publish_at` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `topic_indicator_guid` (`topic_id`,`computation_day`),
  KEY `idx_computation_day` (`computation_day`),
  KEY `idx_topic_computation_publish` (`topic_id`,`computation_day`,`publish_at`)
) ENGINE=InnoDB AUTO_INCREMENT=800561 DEFAULT CHARSET=utf8;
 
我有一张表,表结构如上,UNIQUE KEY `topic_indicator_guid`和KEY `idx_topic_computation_publish`  索引是冗余的。
但是我用
pt-duplicate-key-checker --host=127.0.0.1 --user=root --password=123456 --port=3307 
却没有提示索引冗余,而且我发现如果索引的第一个字段是主键ID,也不会报索引冗余。

解决方案 »

  1.   

    pt-duplicate-key-checker:
    功能为从mysql表中找出重复的索引和外键,这个工具会将重复的索引和外键都列出来,并生成了删除重复索引的语句,
    而lz,表结构如上,UNIQUE KEY `topic_indicator_guid`和KEY `idx_topic_computation_publish`,是2个不同类型索引列
      

  2.   


    `topic_id`,`computation_day`字段
    在idx_topic_computation_publish和topic_indicator_guid索引中都是前置字段。
    这要是不算冗余索引,那什么算。
      

  3.   

    pt-duplicate-key-checker 显然不可信。