Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been monitoring my server the past two days and realised that 60% of my temp tables are stored on the hhd instead of memory. Also I ran MySQL Performance Tuning Primer script that adviced me to set the query_cache_size.

Now, to do this, I believe that I will need to set the query_cache_size and join_buffer_size in my.cnf

Unfortunately, I do not have any experience with editing the my.cnf file so I am hoping that someone can kindly assist me here. How do I set it, and what should I set it to?

my.cnf currently:

[mysqld]
set-variable = max_connections=500
safe-show-database
log_slow_queries = /var/log/mysql/log-slow-queries.log
slow_query_log = 1
long_query_time = 2
log-queries-not-using-indexes
share|improve this question

1 Answer 1

up vote 1 down vote accepted

The possible values (and other information) for the config are available in the MySQL reference guide. So, for example, if I wanted to add the two parameters you specified, your /etc/my.cnf config would resemble the following:

[mysqld]
set-variable = max_connections=500
safe-show-database
log_slow_queries = /var/log/mysql/log-slow-queries.log
slow_query_log = 1
long_query_time = 2
log-queries-not-using-indexes

# (default: 0)
thread_cache_size = 4
# Replaces table_cache in 5.1.3 (default: 64)
table_open_cache = 128
# (default: 0), disables cache
query_cache_size = 8388608

The two values I used were the defaults that MySQL uses if they are not specified. Be sure to specify your own values here!

UPDATE: MySQL's tech resources also has a great article on understanding the cache.

share|improve this answer
    
Thanks for the answer, is there any way that I can find what values I should set them to? It is obvious that they are set to too low currently. –  LittleSnitch Nov 21 '10 at 16:17
    
I added a great article to my answer, but you're definitely going to have to feel it out. Basically, you can check how many hits and misses you have on your query cache, and then tweak accordingly. It also depends on how much memory you have available. –  Andrew M. Nov 21 '10 at 16:26
    
Well im running it on a Xeon 7550 server with 32gb ram. I installed MySQLTuner and it told me to do this changes: query_cache_size (>= 8M) thread_cache_size (start at 4) table_cache (> 64) ... How do I add these changes to my.cnf? Could you kindly add these adjustments to your answer? That would be very helpful buddy. –  LittleSnitch Nov 21 '10 at 16:36
    
They have been added, but you will need to tweak them after monitoring them for performance. –  Andrew M. Nov 21 '10 at 16:47
    
Thank you very much, I will have a read through links to understand it better. –  LittleSnitch Nov 21 '10 at 17:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.