MySQL optimization. Here we will give some quick help on optimizing MySQL database performance.
One of the factors with the biggest impact on database performance is not the MySQL settings, but your queries! Make sure you have optimized all your queries first, and have created the right indexes on your tables for MySQL to use.
A useful MySQL command for this is EXPLAIN. If you use EXPLAIN SELECT * FROM table WHERE field="something" , MySQL will tell you how many rows it needs to search, and what index it can use for this, among other things.
After you have optimized your queries and created indexes, you can start tweaking your my.cnf MySQL configuration file. Keep in mind that if you optimize or change something you should be able to benchmark it to make sure it will actually increase the performance.
Here is a sample my.cnf file (MySQL 4.1) for use on a dual processor server with 2GB of RAM memory:
# The following options will be passed to all MySQL clients
# The MySQL server
# if you are performing GROUP BY or ORDER BY queries on tables that
# are much larger than your available memory, you should increase
# the value of read_rnd_buffer_size to speed up the reading of rows
# following sorting operations.
# but: change the session variable only from within those clients
# that need to run large queries
# increase until threads_created doesnt grow anymore
# Try number of CPU's*2 for thread_concurrency
You can use the SHOW STATUS MySQL command to monitor some of the variables (like Threads_created , Created_tmp_disk_tables , Created_tmp_tables and so on).
If you would like more information, feel free to contact us.