Question: whenever i run mysqltuner it always complain about three components even i change their values to high but still showing need more, they are following, I have both table MyISAM and InnoDB and we do join etc also but i heard it is not good to set join_buffer_size value higher, following is detail of box, please suggest if my box anything more to tune?
Variables to adjust:
query_cache_size (> 128M)
join_buffer_size (> 4.0M, or always use indexes with joins)
table_cache (> 512)
Hardware: 40 CPUs and 64 GB Memory
MySQL: mysql-5.1.73-3.el6_5.x86_64
my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
symbolic-links=0
bind-address = 0.0.0.0
max_connections = 1000
max_allowed_packet=32M
join_buffer_size=4M
thread_cache_size=8
query_cache_limit=4M
query_cache_size=128M
thread_cache_size=4
table_cache=512
key_buffer_size=2G
innodb-buffer-pool-size = 16G
open-files-limit = 35535
sort_buffer_size = 6M
query-cache-type = 1
tmp_table_size=1G
innodb_log_buffer_size=1G
server-id=1
binlog-format = mixed
log-bin=mysql-bin
datadir=/var/lib/mysql
innodb_flush_log_at_trx_commit=1
sync_binlog=1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
mysqltunner
-------- Performance Metrics -------------------------------------------------
[--] Up for: 18h 33m 52s (121M q [1K qps], 4M conn, TX: 32B, RX: 16B)
[--] Reads / Writes: 99% / 1%
[--] Total buffers: 19.1G global + 10.6M per thread (1000 max threads)
[OK] Maximum possible memory usage: 29.5G (46% of installed RAM)
[OK] Slow queries: 0% (4/121M)
[OK] Highest usage of available connections: 8% (88/1000)
[OK] Key buffer size / total MyISAM indexes: 2.0G/1.7G
[OK] Key buffer hit rate: 99.4% (15M cached / 90K reads)
[OK] Query cache efficiency: 71.1% (75M cached / 106M selects)
[!!] Query cache prunes per day: 27253282
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 21M sorts)
[!!] Joins performed without indexes: 12267
[OK] Temporary tables created on disk: 3% (1K on disk / 49K total)
[OK] Thread cache hit rate: 99% (1K created / 4M connections)
[!!] Table cache hit rate: 1% (365 open / 21K opened)
[OK] Open file limit used: 1% (449/35K)
[OK] Table locks acquired immediately: 99% (30M immediate / 30M locks)
[OK] InnoDB data size / buffer pool: 115.6M/16.0G
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
MySQL started within last 24 hours - recommendations may be inaccurate
Enable the slow query log to troubleshoot bad queries
Adjust your join queries to always utilize indexes
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
query_cache_size (> 128M)
join_buffer_size (> 4.0M, or always use indexes with joins)
table_cache (> 512)
Status
mysql> show status LIKE '%open_%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| Com_show_open_tables | 0 |
| Open_files | 449 |
| Open_streams | 0 |
| Open_table_definitions | 169 |
| Open_tables | 365 |
| Opened_files | 7436 |
| Opened_table_definitions | 0 |
| Opened_tables | 0 |
| Slave_open_temp_tables | 0 |
+--------------------------+-------+
9 rows in set (0.00 sec)
mysql> show status LIKE '%key_%';
+------------------------+----------+
| Variable_name | Value |
+------------------------+----------+
| Com_assign_to_keycache | 0 |
| Com_preload_keys | 0 |
| Com_show_keys | 0 |
| Key_blocks_not_flushed | 0 |
| Key_blocks_unused | 1617830 |
| Key_blocks_used | 96906 |
| Key_read_requests | 15325797 |
| Key_reads | 91041 |
| Key_write_requests | 497292 |
| Key_writes | 421837 |
+------------------------+----------+
10 rows in set (0.00 sec)
Notes: We are running nightly mysqldump.
mysqltuner is outputting:
MySQL started within last 24 hours - recommendations may be inaccurate
Be sure,that there is enought request done to be sure mysqltuner is advising you accurately.
Related
I recently migrated a database from a MySQL 5.6 physical server to Percona 5.7 Centos 7 VM.
In the legacy environment, the loading of a 27G CSV file into a single table took 2 hours to complete.
In the new environment, with heavily upgraded resources (RAM, CPUs, etc), it will run for over 24 hours and never complete.
Details:
Server CPU for the mysqld process will spike to over 100% when the job starts and maintain until the process is killed in db or command line.
This is a MyISAM table. (I do not want to hear about InnoDB. This engine is a customer requirement and there is no changing it)
Within 10 seconds, the MYI file for the table will build to 451MB and stop. 5 minutes later, it increases to 939MB within 5-10 seconds and stops again. Up to an hour or two later, it will increase again to 1.6G. 24 hours later, it may reach 6.2G; but does not increase past that point.
Recall that during the 'quiet' times, CPU is at 100+%. IO is zero except during the few seconds it is writing to the MYI file. Server load is 1-2. Memory usage is 27% at most. Disk is SSD. Server has 96G RAM.
The table is truncated before each script run, so bulk_insert_biffer_size is unused. Keys are automatically disabled due to empty table. I have tried tweaking every buffer and nothing changes the results in any way. I have changed the table to InnoDB, with no different except the files are a little bigger; but the stopping points are the same and it does not finish.
I have looked at OS level buffers and caching and have not found anything either.
Ideas?
mysql> show global variables like '%buffer%';
+-------------------------------------+----------------+
| Variable_name | Value |
+-------------------------------------+----------------+
| audit_log_buffer_size | 1048576 |
| bulk_insert_buffer_size | 67108864 |
| innodb_buffer_pool_chunk_size | 134217728 |
| innodb_buffer_pool_dump_at_shutdown | ON |
| innodb_buffer_pool_dump_now | OFF |
| innodb_buffer_pool_dump_pct | 25 |
| innodb_buffer_pool_filename | ib_buffer_pool |
| innodb_buffer_pool_instances | 8 |
| innodb_buffer_pool_load_abort | OFF |
| innodb_buffer_pool_load_at_startup | ON |
| innodb_buffer_pool_load_now | OFF |
| innodb_buffer_pool_size | 10737418240 |
| innodb_change_buffer_max_size | 25 |
| innodb_change_buffering | all |
| innodb_log_buffer_size | 134217728 |
| innodb_sort_buffer_size | 1048576 |
| join_buffer_size | 8388608 |
| key_buffer_size | 26843545600 |
| myisam_sort_buffer_size | 4294967296 |
| net_buffer_length | 16384 |
| preload_buffer_size | 32768 |
| read_buffer_size | 1048576 |
| read_rnd_buffer_size | 10485760 |
| sort_buffer_size | 67108864
Server Cores: 8 CPUs with 8 cores each
set sql_log_bin = 0;
LOCK TABLES t_surescripts_full WRITE;
TRUNCATE TABLE t_surescripts_full;
LOAD DATA LOCAL INFILE '/data/0149561_SS_PRE/SS_PRE_20200108_v44.match_output.just_output_records' INTO TABLE t_surescripts_full CHARACTER SET 'latin1'
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' ESCAPED BY ''
LINES TERMINATED BY '\n';
UNLOCK TABLES;
The processlist is not really helpful as the load data infile is the only query and its status is 'executing', even after 20 hours.
ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 385429
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 10240
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 10240
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
Consider these possibilities, please.
To set sql_bin_log OFF requires the user to have Super_priv as Y.
SELECT host,user,super_priv FROM mysql.user WHERE user = 'somename';
may be used to confirm the super_priv is Y
SET sql_log_bin = 0;
might be more successful with
SET SESSION sql_log_bin = OFF;
to avoid logging 27G of CSV data being loaded.
Please post new time required and see email sent to you this AM for additional details.
My mysqld process consumes 232% CPU and and there 14000+ connections
(I'm a little new to this thing but following Stack Overflow for assistance).
top:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3112 mysql 20 0 7061444 1.397g 15848 S 232.6 8.9 1138:06 mysqld
System:
Ubuntu 18.04,
16GB RAM,
8 Core CPU,
120GB Disk
and MySQL version 5.7.25
mysql> show status like 'Conn%';
+-----------------------------------+-------+
| Variable_name | Value |
+-----------------------------------+-------+
| Connection_errors_accept | 0 |
| Connection_errors_internal | 0 |
| Connection_errors_max_connections | 0 |
| Connection_errors_peer_address | 0 |
| Connection_errors_select | 0 |
| Connection_errors_tcpwrap | 0 |
| Connections | 14007 |
+-----------------------------------+-------+
7 rows in set (0.01 sec)
And show variables like "%timeout%"
mysql> show variables like "%timeout%";
+-----------------------------+----------+
| Variable_name | Value |
+-----------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| have_statement_timeout | YES |
| innodb_flush_log_at_timeout | 1 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| rpl_stop_slave_timeout | 31536000 |
| slave_net_timeout | 60 |
| wait_timeout | 28800 |
+-----------------------------+----------+
13 rows in set (0.01 sec)
And mysqld.cnf settings
[mysqld]
# Skip reverse DNS lookup of clients
skip-name-resolve
default-storage-engine=InnoDB
max_allowed_packet=500M
max_connections = 256
interactive_timeout=7200
wait_timeout=7200
innodb_file_per_table=1
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 4
innodb_log_file_size = 1G
innodb_flush_log_at_trx_commit = 1
innodb_flush_method = O_DIRECT
innodb_open_files=5000
innodb_io_capacity=2000
innodb_io_capacity_max=4000
innodb_old_blocks_time=2000
open_files_limit=50000
query_cache_type = 1
query_cache_min_res_unit = 1M
query_cache_limit = 1M
query_cache_size = 50M
tmp_table_size= 256M
max_heap_table_size= 256M
#key_buffer_size = 128M
thread_stack = 128K
thread_cache_size = 32
slow-query-log = 1
slow-query-log-file = /var/lib/mysql/mysql-slow.log
long_query_time = 1
Note: Corrected above mysqld.cnf values to match with below reports attached
Additional Info:
htop:- https://pastebin.com/43f4b3fK
top:- https://pastebin.com/rTh1XvUt
GLOBAL VARIABLES: https://pastebin.com/K2fgKwEv (Complete)
INNODB STATUS:- https://pastebin.com/nGrZjHAg
Mysqltuner:- https://pastebin.com/ZNYieJj8
[SHOW FULL PROCESSLIST], [ulimit -a], [iostat -xm], [lscpu] :- https://pastebin.com/mrnyQrXf
Server freezes when multiple db transaction is being carried out. Is there a lock like thing or any configuration flaws?
(Background: This is a WordPress blog and nobody else is accessing it right now. I somehow imported a 115K posts from an old blog but struck here with this CPU ghost)
Rate Per Second = RPS - Suggestions to consider for your my.cnf [mysqld] section,
innodb_lru_scan_depth=100 # from 1024 to reduce 90% of cpu cycles used for function every SECOND
innodb_io_capacity=3500 # from 2000 to enable higher IOPS on your SSD devices
innodb_flushing_avg_loops=5 # from 30 to reduce innodb_buffer_pool_pages_dirty overhead - count was 3183 in SGStatus
read_buffer_size=256K # from 128K to reduce handler_read_next RPS of 277,134
read_rnd_buffer_size=192K # from 256K to reduce handler_read_rnd_next RPS of 778
There are many more opportunities to improve performance through Global Variables.
Disclaimer: I am the author of web site mentioned in my profile, Network profile that includes contact information.
A likely cause of high CPU and poor performance is the poor schema for wp_postmeta. I discuss the remedy here.
Meanwhile, "you can't tune your way out of a performance problem". I did glance at the settings -- all are "reasonable".
I have a table partitioned by month and this table has 1.5M rows, for making queries it touches the correct partition and the query runs really fast. I've made my partition on this table because everyday people makes batch insert and everyday this table is growing up, moreover than making batch inserts, we use an app for crud operations and my problems is on insert rows, each insert is taking more than 5segs. I have tracked what's wrong on my process-list and I can see all my inserts are waiting for something, and reminds me when I used to have this table on MyIsam (actually is on Innodb). I'd like to know how can I increment speediness for insert operations on a partition table when they use the web application (or not using batch insert).
My table is on **Mysql 5.1**
Operative System: Debian
InnoDB Setup by Default (I have not made any changes on my.cnf), so any suggestion would be fine.
I have 4G available on free memory according free -g command on Debian.
mysql> SHOW VARIABLES LIKE '%buffer%';
+-------------------------+------------+
| Variable_name | Value |
+-------------------------+------------+
| bulk_insert_buffer_size | 8388608 |
| innodb_buffer_pool_size | 2097152000 |
| innodb_log_buffer_size | 1048576 |
| join_buffer_size | 131072 |
| key_buffer_size | 16777216 |
| myisam_sort_buffer_size | 8388608 |
| net_buffer_length | 16384 |
| preload_buffer_size | 32768 |
| read_buffer_size | 131072 |
| read_rnd_buffer_size | 262144 |
| sort_buffer_size | 2097144 |
| sql_buffer_result | OFF |
+-------------------------+------------+
12 rows in set
The last thing I did was increment Innodb_buffer_pool_size to 2000MB and my server got slower.
I have already tried so many things, and now I am slowly converting the despair.
To my problem, I have already done a lot of adjustments to the MySQL Configuration,
but unfortunately I always get back to time utilization very high CPU.
Multiple MySQL processes partially between 200-750% CPU / Ram usage is ok about 50%.
Information on the system:
Root: HP ProLiant DL120 1Gbps / Intel Quad-Core Xeon X3440 - 16GB Ram / Ubuntu Server operating system
There are 3 databases (3 sites), each with 16 tables | DB_1 = 35MB - 560MB DB_2 = - = DB_3 3,4GB
Websites are optimized (database queries / cache, etc.) | visitors per day about 15K / day per page
At the root runs only Nginx + PHP5-FPM and mySQL, and all 8 processors are completely overloaded.
MySQLTuner edition:
>> MySQLTuner 1.1.1 - 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.5.44-0ubuntu0.14.04.1
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 65K (Tables: 2)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[--] Data in InnoDB tables: 3G (Tables: 44)
[!!] Total fragmented tables: 18
-------- Security Recommendations -------------------------------------------
[OK] All database users have passwords assigned
-------- Performance Metrics -------------------------------------------------
[--] Up for: 4s (991 q [247.750 qps], 73 conn, TX: 8M, RX: 91K)
[--] Reads / Writes: 99% / 1%
[--] Total buffers: 12.5G global + 3.6M per thread (100 max threads)
[OK] Maximum possible memory usage: 12.8G (81% of installed RAM)
[OK] Slow queries: 0% (8/991)
[OK] Highest usage of available connections: 28% (28/100)
[OK] Key buffer size / total MyISAM indexes: 256.0M/120.0K
[!!] Query cache efficiency: 17.8% (155 cached / 873 selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 26 sorts)
[OK] Temporary tables created on disk: 20% (61 on disk / 302 total)
[OK] Thread cache hit rate: 61% (28 created / 73 connections)
[OK] Table cache hit rate: 95% (138 open / 145 opened)
[OK] Open file limit used: 5% (52/1K)
[OK] Table locks acquired immediately: 100% (712 immediate / 712 locks)
[OK] InnoDB data size / buffer pool: 3.4G/7.8G
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
MySQL started within last 24 hours - recommendations may be inaccurate
Enable the slow query log to troubleshoot bad queries
MySQL Configuration I have so often changed, can not think of the current "my.cnf":
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
bind-address = 127.0.0.1
# Tunning #
tmp_table_size = 4000M
max_heap_table_size = 4200M
max_connections = 100
max_allowed_packet = 16M
thread_cache_size = 32M
query_cache_size = 512M
query_cache_min_res_unit = 4K
sort_buffer_size = 2M
join_buffer_size = 128K
preload_buffer_size = 32K
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 256K
low_priority_updates = 1
concurrent_insert = ALWAYS
# INNODB #
innodb_log_files_in_group = 2
innodb_log_file_size = 256M
innodb_file_per_table = 1
innodb_buffer_pool_instances = 8
innodb_buffer_pool_size = 8000M
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_thread_concurrency = 0
# Logging
log_warnings = 2
log_error = /var/log/mysql/error.log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 1
log_queries_not_using_indexes = 1
min_examined_row_limit = 20
# Binary Log / Replication
server_id = 1
binlog_cache_size = 1M
sync_binlog = 8
binlog_format = row
expire_logs_days = 7
max_binlog_size = 128M
relay-log = /var/log/mysql/slave-relay.log
relay-log-index = /var/log/mysql/slave-relay-log.index
[mysqldump]
quick
single-transaction
max_allowed_packet = 8M
[mysql]
no_auto_rehash
[myisamchk]
key_buffer = 265M
read_buffer = 8M
write_buffer = 8M
[mysqld_safe]
open-files-limit = 8192
log-error = /var/log/mysql/error.log
!includedir /etc/mysql/conf.d/
key_buffer = 8M
max_allowed_packet = 8M
thread_stack = 192K
thread_cache_size = 4
[mysqldump]
quick
quote-names
max_allowed_packet = 8M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[isamchk]
key_buffer = 8M
!includedir /etc/mysql/conf.d/
PROCESSLIST Output:
mysql> SHOW PROCESSLIST;
+-------+---------+-----------+-------------+---------+------+----------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-------+---------+-----------+-------------+---------+------+----------------------+------------------------------------------------------------------------------------------------------+
| 251 | pb_root | localhost | db_name | Sleep | 1 | | NULL |
| 48726 | root | localhost | NULL | Query | 0 | NULL | SHOW PROCESSLIST |
| 48775 | pb_root | localhost | db_name | Sleep | 0 | | NULL |
| 48838 | ww_root | localhost | db_name | Query | 1 | Copying to tmp table | SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts |
| 48845 | ww_root | localhost | db_name | Query | 0 | Copying to tmp table | SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts |
| 48846 | ww_root | localhost | db_name | Query | 0 | preparing | SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (wp_posts.ID NOT IN ( |
| 48847 | ww_root | localhost | db_name | Sleep | 0 | | NULL |
| 48854 | pb_root | localhost | db_name | Sleep | 1 | | NULL |
| 48735 | pb_root | localhost | db_name | Sleep | 0 | | NULL |
| 48878 | ww_root | localhost | db_name | Query | 1 | Copying to tmp table | SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts |
| 48845 | pb_root | localhost | db_name | Query | 0 | Copying to tmp table | SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts |
| 48827 | ww_root | localhost | db_name | Sleep | 0 | | NULL |
+-------+---------+-----------+-------------+---------+------+----------------------+------------------------------------------------------------------------------------------------------+
I try my problems actually getting yourself to solve somehow, but unfortunately I'm really at a loss now.
Please check below remarks, if it helps you-
tmp_table_size = 4000M #reduce it to 256M even should be lower but set at this time. Also there should be space in /tmp partiont at least equal or greate to this variable.
max_heap_table_size = 4200M #should be same as tmp_table_size so set it 256M
max_connections = 100
max_allowed_packet = 16M
thread_cache_size = 32M #It should be in numbers set it to 50 for re-use.
query_cache_size = 512M #as your mysql tuner report is showing very less use of query_cache so you can disable it or reduce to 20M
query_cache_limit = 2M #add it if use above query_cache_size variable else no need.
query_cache_min_res_unit = 4K #can comment it.
sort_buffer_size = 2M
join_buffer_size = 128K
preload_buffer_size = 32K #can comment it for testing.
key_buffer_size = 256M #keep it 50M if not using myisam tables and your server is innodb.
read_buffer_size = 1M
read_rnd_buffer_size = 256K
low_priority_updates = 1 #comment it for testing purpose further you can on as per your requirement.
concurrent_insert = ALWAYS
# INNODB #
innodb_log_files_in_group = 2
innodb_log_file_size = 256M #this can create increase mysql restart time, for mysql 5.5 it is default 5M so you can set as per requirement but 256M is seems too high means you are allocating 500M to log file.
innodb_file_per_table = 1
innodb_buffer_pool_instances = 8
innodb_buffer_pool_size = 8000M
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_thread_concurrency = 0
# Binary Log / Replication
binlog_cache_size = 1M #comment it and keep default as it uses server resources per connection if not set it high due to any specific reason.
Except this so many sections are duplicate in your config file like mysqld_safe and mysqldump.
Also mysqltuner report is showing that 20% temp table is creating on disk means queries are not optmized or not using index.
Need to check slow queries and optimize them.
As per my experience SQL_CALC_FOUND_ROWS kill the performance, so you should use count intead of this.
In my configuration innodb_flush_method=O_DSYNC from O-DIRECT reduces about 75% the iowait, and accordingly this the load. Should I set another variables besides innodb_flush_method to reduce more the iowait?
My configuration file is:
[mysqld]
innodb_file_per_table=1
query_cache_size=128M
thread_cache_size=64
key_buffer_size=32M
max_allowed_packet=16M
table_cache=1024
table_definition_cache=8192
wait_timeout=20
max_user_connections=25
innodb_flush_method=O_DSYNC
open_files_limit=16384
myisam_sort_buffer_size=2M
collation_server=utf8_unicode_ci
character_set_server=utf8
tmp_table_size = 384M
max_heap_table_size = 384M
innodb_buffer_pool_size=64M
innodb_thread_concurrency=8
max_connections=125
I have a database with 100 Innodb tables, 3 of them has about 25000 records, the others has no significant records. The average queries in peak time is about 160, the majority is SELECT
innodb_buffer_pool_size
Major problem is innodb_buffer_pool_size is too small. Recommandation is set to 50~75% of main memory.
innodb_buffer_pool_size=64M
I strongly recommand that you should increase it's value.
Generally speaking, O_DIRECT is little bit fast because InnoDB Buffer Pool caches Data+Index, So with O_DIRECT disabled File System Page Cache is faster. MySQL Manaual says
( http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_flush_method)
Depending on hardware configuration, setting innodb_flush_method to O_DIRECT can either have either a positive or negative effect on performance. Benchmark your particular configuration to decide which setting to use.
But in my experience, there was no significant difference between O_DIRECT and O_DSYNC. Both SSD and HDD are test.
Anyway you should increase innodb_buffer_pool_size.
Calculating innodb buffer pool hit ratio
mysql> SHOW GLOBAL STATUS LIKE '%innodb%';
+---------------------------------------+-------------+
| Variable_name | Value |
+---------------------------------------+-------------+
.....
.....
| Innodb_buffer_pool_read_requests | 11054273949 |
| Innodb_buffer_pool_reads | 135237 |
| Innodb_buffer_pool_wait_free | 0 |
....
innodb buffer pool hit ratio = ((Innodb_buffer_pool_read_requests) / (Innodb_buffer_pool_read_requests + Innodb_buffer_pool_reads)) * 100
E.g. above examples,
hit ratio = (11054273949 / (11054273949 + 135237)) * 100 = 99.99%
I think this value is too small in your case.
query_cache_size
"the majority is SELECT"
If most queries are SELECT and update query is rare, I think increasing query_cache_size is very helpful for you.
Could you post your query cache status as follows?
mysql> show global status like 'Qc%';
+-------------------------+------------+
| Variable_name | Value |
+-------------------------+------------+
| Qcache_free_blocks | 13 |
| Qcache_free_memory | 1073403104 |
| Qcache_hits | 217949 |
| Qcache_inserts | 337009 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 2122598 |
| Qcache_queries_in_cache | 68 |
| Qcache_total_blocks | 167 |
+-------------------------+------------+
mysql> show global status like 'com_select%';
+---------------+---------+
| Variable_name | Value |
+---------------+---------+
| Com_select | 3292531 |
+---------------+---------+
1 row in set (0.00 sec)
Calculating innodb buffer pool hit ratio
query cache hit ratio = ((Qcache_hits) / (Qcache_hits + Com_select)) * 100
first, figure out your query cache hit ratio.