开发者

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

开发者 https://www.devze.com 2023-02-12 03:47 出处:网络
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 d

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.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号