Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have already optimize many times my Mysql server but now I want to have your advices.

mysqltuner:

-------- 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)

tuning-primer:

SLOW QUERIES
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

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

WORKER THREADS
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

MAX CONNECTIONS
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.

INNODB STATUS
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

MEMORY USAGE
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

KEY BUFFER
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
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

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

JOINS
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.

OPEN FILES LIMIT
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

TABLE CACHE
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

TEMP TABLES
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.

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

TABLE LOCKING
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 ?

Thanks

share|improve this question

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 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

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.
{"cc_re__cc_re__cc_by_sa_3_0": ["                    <li><a href=\"//area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"//careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2016 Stack Exchange Inc; user contributions licensed under <a href=\"https://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2016.4.29.3525\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Server Fault works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </noscript>\r\n\r\n    <s"], "copyright__copyright__copyright": ["time.\n\nAlso 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.\n\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}