Repair table [table name] quick; [provided corruption occurred in index file]
This repair method attemps to “repair by key cache”. The approach is okay if you are dealing with small tables. However, this can take forever for large MyISAM tables. The best approach to repair large multi-gigabyte MyISAM tables is using sort method. Following methods repairs table via sort mechanism:
USING MYISAMCHK:
1. Create a copy of corrupted file and run following command :
myisamchk --sort-recover --sort-buffer-size=2G
This would repair the table using sort method. You can also specify tmpdir at command prompt i.e
myisamchk --sort-recover --sort-buffer-size=2G
Make sure tmpdir has enough space available.
Once repaired, repair corrupted file with this repaired file.
As a good practice, always keep a backup of original file.
USING myisam_max_sort_file_size:
This variable specifies maximum size of the temporary file that MySQL can use to repair a table. If the file size will be larger, repair is done using key cache method. Set it to a real high value and then use the repair command:
1. set global myisam_max_sort_file_size=223372036853727231;
2. repair table table_name;
Repairing tables (for example 20GB+) can be a big pain. It is very important to understand various repair options available, and choose the right strategy