MySQL Forums
Forum List  »  Performance

Help to improve MySQL performances
Posted by: super scraly
Date: April 19, 2012 07:22AM

Hi,

I am a developer, not a MySQL expert but i've tried to optimize severals variables of my mysql server which replicate datas to one slave, and now I want to know what others optimisations whould be great and usefull.

Here some informations, please tell me if you want more informations. Thanks by advance.


MySQL 5.1.58
centos 64bits

$ mysqltuner.pl
>> MySQLTuner 1.2.0 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering

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

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 22G (Tables: 28)
[--] Data in InnoDB tables: 88M (Tables: 37)
[!!] Total fragmented tables: 43

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

-------- Performance Metrics -------------------------------------------------
[--] Up for: 30d 21h 7m 40s (692M q [259.672 qps], 874K conn, TX: 255B, RX: 143B)
[--] Reads / Writes: 70% / 30%
[--] Total buffers: 2.4G global + 8.2M per thread (270 max threads)
[OK] Maximum possible memory usage: 4.6G (39% of installed RAM)
[OK] Slow queries: 0% (12K/692M)
[OK] Highest usage of available connections: 80% (216/270)
[OK] Key buffer size / total MyISAM indexes: 2.0G/3.6G
[OK] Key buffer hit rate: 96.7% (2B cached / 78M reads)
[OK] Query cache efficiency: 34.3% (88M cached / 257M selects)
[!!] Query cache prunes per day: 17218
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 2M sorts)
[!!] Temporary tables created on disk: 28% (836K on disk / 2M total)
[OK] Thread cache hit rate: 99% (4K created / 874K connections)
[!!] Table cache hit rate: 8% (284 open / 3K opened)
[OK] Open file limit used: 12% (127/1K)
[OK] Table locks acquired immediately: 99% (311M immediate / 311M locks)
[OK] InnoDB data size / buffer pool: 88.8M/200.0M

-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Temporary table size is already large - reduce result set size
Reduce your SELECT DISTINCT queries without LIMIT clauses
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
query_cache_size (> 20M)
table_cache (> 342)

I run an optimize tables every monday.

$ tuning-primer.sh

-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -

MySQL Version 5.1.58-log x86_64

Uptime = 30 days 21 hrs 7 min 44 sec
Avg. qps = 259
Total Questions = 692820338
Threads Connected = 34

Server has been running for over 48hrs.
It should be safe to follow these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is enabled.
Current long_query_time = 5.000000 sec.
You have 12580 out of 692820391 that take longer than 5.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 = 5
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 270
Current threads_connected = 34
Historic max_used_connections = 216
The number of used connections is 80% of the configured maximum.
Your max_connections variable seems to be fine.

INNODB STATUS
Current InnoDB index space = 33 M
Current InnoDB data space = 88 M
Current InnoDB buffer pool free = 0 %
Current innodb_buffer_pool_size = 200 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.91 G
Configured Max Per-thread Buffers : 2.18 G
Configured Max Global Buffers : 2.16 G
Configured Max Memory Limit : 4.35 G
Physical Memory : 11.73 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 3.57 G
Current key_buffer_size = 1.95 G
Key cache miss rate is 1 : 30
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 = 14 M
Current query_cache_limit = 4 M
Current Query cache Memory fill ratio = 71.48 %
Current query_cache_min_res_unit = 2 K
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 4300 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 = 342 tables
Current table_definition_cache = 256 tables
You have a total of 88 tables
You have 284 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 256 M
Current tmp_table_size = 256 M
Of 2148388 temp tables, 28% 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 = 4 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 13360
Your table locking seems to be fine
mysql> SHOW GLOBAL STATUS LIKE 'threads_running';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| Threads_running | 2 |
+-----------------+-------+
1 row in set (0.00 sec)

mysql> SHOW STATUS LIKE 'Max_used_connections';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| Max_used_connections | 216 |
+----------------------+-------+
1 row in set (0.00 sec)



$ free -m
total used free shared buffers cached
Mem: 12011 11936 75 0 328 5997
-/+ buffers/cache: 5610 6401
Swap: 1027 0 1027

Moreover, I have some rollbacked transactions so that's why too I want to improve the performances :-).

Thanks! :-)



Edited 2 time(s). Last edit at 04/20/2012 04:26AM by super scraly.

Options: ReplyQuote


Subject
Views
Written By
Posted
Help to improve MySQL performances
11188
April 19, 2012 07:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.