Making MySQL Use More Memory: Part 2
March 26th, 2009 by Scott SelikoffIn a previous article, I discussed how to get the most out of your memory usage in MySQL systems using the InnoDB storage engine. To review, MySQL has overly conservative memory usage by default. Your MySQL instance may be using only a small fraction of the available memory, leading to unnecessarily poor application performance. In this article, I’ll discuss how to accomplish the same feat in a MyISAM storage engine.
One of the main variables for increasing the memory usage in MyISAM is the “key_buffer_size”, which is the key cache for MyISAM systems. Set “key_buffer_size” to be up to 25% of RAM, or at least a few hundred megabytes. For example, if you have 2GB of RAM, you may want to set it as follows:
key_buffer_size=500M
You can set this value up to 50% of available memory, although be careful to keep (key_buffer_size + innodb_buffer_pool_size) < 80% of available memory. Assuming your system is primarily an InnoDB xor a MyISAM system, only one of these values should be set large.
Next, increase the size of the MyISAM sort buffer size. I don’t really have a recommended size here, but a few hundred megabytes should suffice such as:
myisam_sort_buffer_size=256M
Some other less used parameters with suggested values:
read_buffer_size=4M
sort_buffer_size=4M
myisam_max_sort_file_size=20G
Note that the last parameter increases the temporary file space, not memory, but may lead to improved performance.
Posted: 26 March, 2009 in Database.
Tags: Database, myisam, performance
Comments
Comment from Simon
Posted: September 23, 2009 at 1:28 pm
Great tips, bear in mind that if you’re putting in bit values you need to do the following:
1024*1024 = 1048576 = 1M
and
1024*1024*1024 = 1073741824 = 1G

Comment from Ivan
Posted: July 8, 2009 at 4:25 pm
Made it but memory usage is now lower… why!!??