简体   繁体   中英

mysql optimize table or create a new one

I have a MySQL MyISAM table which has 6.5G overhead. I'm in doubt whether I should optimize the table, or just create a new one, populate from the old one and rename it.

This is a production environment so downtime should be as little as possible. What's the best way to do this?

Creating a new table and transposing the data will mean that the original is still readable, however, if you're allowing writes to it, those writes will have to be transposed after the copy is complete. The optimize procedure is more reliable since it won't allow writes until the operation is complete, but as you note this does involve some down-time.

It really depends if there's enough write activity on this table to cause problems.

You should probably restore this database from a back-up on a test machine and try several different ways to perform this operation before committing to one on your production system.

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