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 already optimize many times my Mysql server but now I want to have your advices.


-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.52-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster 
[--] Data in MyISAM tables: 26G (Tables: 36)
[--] Data in InnoDB tables: 221M (Tables: 35)
[!!] Total fragmented tables: 41

-------- Security Recommendations  -------------------------------------------
[!!] User '@localhost' has no password set.

-------- Performance Metrics -------------------------------------------------
[--] Up for: 78d 11h 57m 53s (1B q [151.485 qps], 1M conn, TX: 336B, RX: 218B)
[--] Reads / Writes: 60% / 40%
[--] Total buffers: 2.2G global + 8.2M per thread (300 max threads)
[OK] Maximum possible memory usage: 4.6G (39% of installed RAM)
[OK] Slow queries: 0% (55K/1B)
[OK] Highest usage of available connections: 69% (209/300)
[OK] Key buffer size / total MyISAM indexes: 2.0G/6.1G
[OK] Key buffer hit rate: 98.2% (2B cached / 47M reads)
[OK] Query cache efficiency: 28.9% (79M cached / 276M selects)
[!!] Query cache prunes per day: 102031
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 3M sorts)
[OK] Temporary tables created on disk: 25% (1M on disk / 3M total)
[OK] Thread cache hit rate: 98% (16K created / 1M connections)
[!!] Table cache hit rate: 7% (330 open / 4K opened)
[OK] Open file limit used: 14% (149/1K)
[OK] Table locks acquired immediately: 99% (489M immediate / 490M locks)
[!!] InnoDB data size / buffer pool: 221.3M/128.0M

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
    query_cache_size (> 20M)
    table_cache (> 400)
    innodb_buffer_pool_size (>= 221M)


The slow query log is enabled.
Current long_query_time = 1.000000 sec.
You have 56239 out of 1027500028 that take longer than 1.000000 sec. to complete
Your long_query_time seems to be fine

The binary update log is enabled
Binlog sync is not enabled, you could loose binlog records during a server crash

Current thread_cache_size = 10
Current threads_cached = 7
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

Current max_connections = 300
Current threads_connected = 26
Historic max_used_connections = 209
The number of used connections is 69% of the configured maximum.
Your max_connections variable seems to be fine.

Current InnoDB index space = 28 M
Current InnoDB data space = 221 M
Current InnoDB buffer pool free = 0 %
Current innodb_buffer_pool_size = 128 M
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory

Max Memory Ever Allocated : 3.78 G
Configured Max Per-thread Buffers : 2.42 G
Configured Max Global Buffers : 2.09 G
Configured Max Memory Limit : 4.52 G
Physical Memory : 11.73 G
Max memory limit seem to be within acceptable norms

Current MyISAM index space = 6.09 G
Current key_buffer_size = 1.95 G
Key cache miss rate is 1 : 54
Key buffer free ratio = 0 %
You could increase key_buffer_size
It is safe to raise this up to 1/4 of total system memory;
assuming this is a dedicated database server.

Query cache is enabled
Current query_cache_size = 20 M
Current query_cache_used = 6 M
Current query_cache_limit = 4 M
Current Query cache Memory fill ratio = 33.45 %
Current query_cache_min_res_unit = 4 K
Query Cache is 30 % fragmented
Run "FLUSH QUERY CACHE" periodically to defragment the query cache memory
If you have many small queries lower 'query_cache_min_res_unit' to reduce fragmentation.
MySQL won't cache query results that are larger than query_cache_limit in size

Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 2 M
Sort buffer seems to be fine

Current join_buffer_size = 2.00 M
You have had 12284 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.

Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.

Current open_files_limit = 1024 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

Current table_open_cache = 400 tables
Current table_definition_cache = 256 tables
You have a total of 94 tables
You have 330 open tables.
The table_cache value seems to be fine

Current max_heap_table_size = 128 M
Current tmp_table_size = 128 M
Of 2988791 temp tables, 25% were created on disk
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your 
ratio of on disk temp tables.

Current read_buffer_size = 2 M
Current table scan ratio = 5 : 1
read_buffer_size seems to be fine

Current Lock Wait ratio = 1 : 5129
Your table locking seems to be fine

And memory infos:

[air@prod01 ~]$ free -m
         total       used       free     shared    buffers     cached
Mem:         12011      11926         85          0        406       6395
-/+ buffers/cache:       5123       6887
Swap:         1027          0       1027

query infos:

mysql>  show status like "Qc_%";
| Variable_name           | Value     |
| Qcache_free_blocks      | 3447      |
| Qcache_free_memory      | 13968768  |
| Qcache_hits             | 79867788  |
| Qcache_inserts          | 163036705 |
| Qcache_lowmem_prunes    | 8012726   |
| Qcache_not_cached       | 33127499  |
| Qcache_queries_in_cache | 3758      |
| Qcache_total_blocks     | 11259     |

I have increase table_open_cache value at 330 to 400.

Should I do something in order to have some better performances ?


share|improve this question
Did you try my recommendations? Whats the status? –  TechZilla Sep 18 '11 at 20:40
add comment

2 Answers

The first step you should do is to install some performance graphing software and start using it to graph your server's vital statistics.

One of these two will do the job: Better Cacti Templates or Appaloosa Zabbix Templates

Once that is in place and you can see what your normal workload looks like, then start changing values and seeing what difference they make.

If you aren't measuring your performance, any changes you make are little more than guessing.

share|improve this answer
I have already better cacti templates ;) –  scraly Sep 9 '11 at 14:08
A lot of optimzation is taking educated guesses. Once you are confident of an issue, you take a guess at what would be the most appropriate changes. Sometimes you over or under shoot the target, you then change it again. Its like a journey, not a destination. Also I wouldn't say he posted too little information, for some obvious basic changes. –  TechZilla Sep 9 '11 at 14:21
add comment

I have done most of my optimizing on MyISAM, (Most my DB's are < 3% writes) However, I do have some general MySQL optimizations for you to consider. In order of priority, in regards to your situation.

  1. Total fragmented tables: 41

This is very high considering you only have 71 tables. With such a heavy proportion of writes to reads, in your case, it explains the reason. I would optimize all your databases. This is most effective on the MyISAM tables, but they make up most your data. Don't stop this command half-way!

 mysqlcheck --all-databases --optimize
  1. Query cache prunes per day: 102031

This is excessive, and almost would explain why your query cache efficiency could be better. Do what mysqltuner suggests, raise that 20M to something more like 64M. (if that is too aggressive you could lower it, but it may end up being too conservative) look for this line in your my.cnf under the mysqld section, and change your 20M to 64M

query_cache_size = 64M
  1. innodb_buffer_pool_size (>= 221M)

You want a buffer pool that is 10% larger then your table data. So something more like 245, but i would really go 250 (makes it even, gives some room) Change your line from 221M to 250M.

innodb_buffer_pool_size = 250M

That's what i can safely recommend without more information, I would guess you need to raise that table_cache also. I'm not sure though what would be best, you would want to check your open tables over some time.

Also make sure your write heavy tables are using InnoDB, read heavy I would go MyISAM. Some applications use those InnoDB only abilities, which should be considered. Some would argue one engine or the other all the time, for different reasons. It is just what I would do.

share|improve this answer
add comment

Your Answer


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.