简体   繁体   English

MySQL如何在不触发修复的情况下向innodb表添加新的多列索引?

[英]MySQL How to add a new multicolumn index to an innodb table without triggering a repair?

I have an innodb table that contains 70 million records and already has several single column indexes. 我有一个innodb表,其中包含7000万条记录,并且已经有几个单列索引。 I want to add a new multicolumn index that would allow me to run queries on multiple columns. 我想添加一个新的多列索引,该索引使我可以在多列上运行查询。 I don't mind limited downtime (less than a day) but I want to avoid a repair with keycache or any other issues that might cause the addition of the new index to take a few days or weeks. 我不介意限制停机时间(少于一天),但是我想避免使用键高速缓存进行维修或其他可能导致添加新索引花费几天或几周的问题。

With the table being innodb, can the new index be added fairly quickly using CREATE INDEX, or would I need to back up the table and recover it to a new table with the desired indexes already added as is recommended for MyISAM tables? 在表为innodb的情况下,是否可以使用CREATE INDEX相当快地添加新索引,还是我需要备份表并将其恢复到已经添加了所需索引的新表中,如MyISAM表所建议的那样? Or is there another strategy that is better suited to innodb? 还是有另一种更适合innodb的策略?

Welcome to hell. 欢迎来到地狱。 I think you have two choices: 我认为您有两种选择:

  1. suffer the downtime. 遭受停机。 Just to commiserate, I have a table with almost 400M rows.. 只是为了慰问,我有一张有近400M行的表。
  2. create a new table. 创建一个新表。 Move your live app to that and then migrate your old data into it in batches. 将您的实时应用程序移至该应用程序,然后将旧数据批量迁移到该应用程序中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM