After Chris' great post,
What's faster than ALTER, I got thinking about REPAIR. REPAIR TABLE can be slow, but may seem necessary if your table is corrupt.
A little background:
MyISAM tables are prone to corruption if they are receiving updates/inserts/deletes/etc and your server crashes. Doing a REPAIR TABLE can generally "fix" them, but it can take time. The larger the table, the longer it takes. How long? Well, a
rough approximation that I use is:
Size of table |
Approximate time |
KBs |
N seconds |
MBs |
N minutes |
GBs |
N hours |
So a several-hundred GB table can take a long time (several days) to repair.
What's the alternative? If you have a backup of the table, you can restore it. That means copy the backup of the .frm, .MYD and .MYI files into the database directory. Then you'll want to restore the activity since your backup. You may be able do this with the binary logs, however, there is no option for restoring just a single table from the binary log. There's a good reason why MySQL didn't include this option. Tables are not always updated in seclusion from one another. You might have multi-table updates or queries such as INSERT..SELECT. But, if you are confident that it would be safe to extract just the DML for this table and re-execute it, then you could use grep. See Beat's
blog post on this.
The restore is likely to be much faster than a REPAIR table.
You need to be a member of Everything MySQL to add comments!
Join Everything MySQL