简体   繁体   中英

MySQL add index on relatively big table (InnoDB)

I have a relatively big InnoDB table (~20m rows) and I want to add an index to a column.

The table is being read from and written to frequently, so I want the table to still be usable while the index is being added.

How can I achieve this?

I currently see two options:

  • Just blindly add the index and pray nothing will happen
  • Creating a replica table with the structures + the index, add the data from the original table and then rename the replica to the original and dropping the original.

Is there a better way?

Thanks :)

MySQL version: 5.0.51

2nd option would be great but how can you achieve this? I recommend MySQL Workbench

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