MySQL :: MySQL 8.4 Reference Manual :: 6.6.4.6 myisamchk Memory Usage (original) (raw)

6.6.4.6 myisamchk Memory Usage

Memory allocation is important when you runmyisamchk. 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 \
           --key_buffer_size=512M \
           --read_buffer_size=64M \
           --write_buffer_size=64M ...

Using --myisam_sort_buffer_size=16M is probably enough for most cases.

Be aware that myisamchk uses temporary files in TMPDIR. If TMPDIR points to a memory file system, out of memory errors can easily occur. If this happens, run myisamchk with the--tmpdir=dir_name option to specify a directory located on a file system that has more space.

When performing repair operations, myisamchk also needs a lot of disk space:

(largest_key + row_pointer_length) * number_of_rows * 2  

You can check the length of the keys and the_rowpointerlength_ withmyisamchk -dv_tbl_name_ (seeSection 6.6.4.5, “Obtaining Table Information with myisamchk”). The_rowpointerlength_ and_numberofrows_ values are theDatafile pointer and Data records values in the table description. To determine the largestkey value, check the Key lines in the table description. The Len column indicates the number of bytes for each key part. For a multiple-column index, the key size is the sum of the Len values for all key parts.

If you have a problem with disk space during repair, you can try--safe-recover instead of--recover.