Most Important MySQL Configuration variables for performance
Show Variables
mysql> SHOW VARIABLES LIKE ‘%buffer%;
or:
shell> mysqladmin variables
Set Variables
mysql> SET GLOBAL key_buffer_size = 10000000;
or:
set it in my.ini
The following are the most important configuration variables in terms of overall performance:
key_buffer_size
Size of the buffer used for index blocks. On a dedicated server, this should usually be about 25% of total RAM. Depending on the operating system, you may be able to increase it beyond this value, but anything above 50% of RAM is liable to be counterproductive due to paging effects caused by the fact that MySQL does not cache data reads from the files, leaving this to be handled by the operating system.
table_cache
Number of open tables for all threads. If your application requires a lot of tables to be open at the same time, try increasing the size of the table_cache variable.
You can see if this needs to be increased by checking the value of the Open_tables variable.
read_buffer_size
Each thread that does a sequential scan allocates a buffer of this size for each table it scans.
If you do many sequential scans(check the value of Handler_read_rnd_next), you should first try adding table indexes or optimizing existing ones. If that doesn’t work or isn’t feasible, you may want to increase this value.
sort_buffer_size
Size of the sort memory buffer allocated to each thread. This can be increased to speed up ORDER BY and GROUP BY queries. The default is 2MB.
If you’re doing a lot of ORDER BY and/or GROUP BY queries that return large resultsets, you may find that increasing the value of sort_buffer_size helps. You may need to experiment with this. Try increasing it in increments of 5% to 10% of the starting value to see if and by how much this speeds up large queries of this type.
net_buffer_length
Size to which MySQL’s communication buffer is reset between queries. This normally should not be changed; however, to gain a small performance improvement on systems with little memory, it can be can set to the expected length of SQL statements sent by clients.
In situations where memory is at a premium or you have a very high number of connections, you may be able to improve matters by adjusting the size of net_buffer_length. However, if you set this value to be too small, you’ll waste any performance gain you might have otherwise obtained, because MySQL will need to keep resetting this value in order to accommodate queries that are longer than the stated number of bytes.