Memory allocation is important when you run myisamchk. myisamchk uses no more memory than its memory-related variables are set to. If you are going to use myisamchk on very large tables, you should first decide how much memory you want it to use. The default is to use only about 3MB to perform repairs. By using larger values, you can get myisamchk to operate faster. For example, if you have more than 512MB RAM available, you could use options such as these (in addition to any other options you might specify):
myisamchk --myisam_sort_buffer_size=256M \
--myisam_sort_buffer_size=16M is probably
enough for most cases.
Be aware that myisamchk uses temporary files
points to a memory file system, out of memory errors can easily
occur. If this happens, run myisamchk with
option to specify a directory located on a file system that has
When performing repair operations, myisamchk also needs a lot of disk space:
Twice the size of the data file (the original file and a copy). This space is not needed if you do a repair with
--quick; in this case, only the index file is re-created. This space must be available on the same file system as the original data file, as the copy is created in the same directory as the original.
Space for the new index file that replaces the old one. The old index file is truncated at the start of the repair operation, so you usually ignore this space. This space must be available on the same file system as the original data file.
--sort-recover(but not when using
--safe-recover), you need space on disk for sorting. This space is allocated in the temporary directory (specified by
--tmpdir=). The following formula yields the amount of space required:
You can check the length of the keys and the
row_pointer_lengthwith myisamchk -dv
tbl_name(see Section 126.96.36.199, “Obtaining Table Information with myisamchk”). The
number_of_rowsvalues are the
Data recordsvalues in the table description. To determine the
largest_keyvalue, check the
Keylines in the table description. The
Lencolumn indicates the number of bytes for each key part. For a multiple-column index, the key size is the sum of the
Lenvalues for all key parts.