简体   繁体   中英

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. 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? Or is there another strategy that is better suited to 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..
  2. create a new table. Move your live app to that and then migrate your old data into it in batches.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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