Session 3. MySQL Performance and Tuning_full_notes
Session 3. MySQL Performance and Tuning_full_notes
Sumi Ryu
Senior Sales Consultant
mysqlslap http://dev.mysql.com/doc/refman/5.6/en/mysqlslap.html
supersmack http://vegan.net/tony/supersmack/
mybench http://jeremy.zawodny.com/mysql/mybench/
SysBench http://sysbench.sourceforge.net/
DBT2 http://osdldbt.sourceforge.net/
http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html
http://dev.mysql.com/doc/refman/5.6/en/server-status-variables.html
5.6
– Updated Defaults for Modern Systems
– Auto-sized Variables
Prior to 5.6
– Out-of-date Configuration File Samples
example: my-innodb-heavy-4G.cnf
Advice:
– Consider 5.6 Defaults
– Re-evaluate older config file entries
innodb_flush_log_at_trx_commit ( caution )
1 sync to file (fsync) on each commit
0/2 may lose 1 second of data
innodb_flush_method=O_Direct
– depends on workload and hardware
innodb_buffer_pool_instances = 8
– 5.5 and 5.6 only
http://dev.mysql.com/doc/refman/5.6/en/innodb-parameters.html
Caches
– key_buffer_cache – 25% of Available Memory
– System Cache – 75% of Available Memory
Multiple Key Buffers
Pre-load Key Buffers
Details:
– http://dev.mysql.com/doc/refman/5.6/en/myisam-key-cache.html
tmp_table_size created_tmp_disk_tables
http://dev.mysql.com/doc/refman/5.6/en/internal-temporary-tables.html
join_buffer_size
– joins that don’t use indexes
– minimum allocated per join per thread
Advice
– leave default
– set dynamically
– benchmark
– tune query
innodb_log_file_size read_rnd_buffer_size
innodb_flush_log_at_trx_commit
innodb_flush_method
innodb_buffer_pool_instances (5.5, 5.6+)
table_open_cache
thread_cache_size
query cache (turn off?)
tmp_table_size (per session)
innodb_flush_log_at_trx_commit
innodb_flush_method
innodb_buffer_pool_instances 1->8
table_open_cache 400->2000 – https://blogs.oracle.com/supporting
thread_cache_size 0->8+max_con/100 mysql/entry/server_defaults_chang
es_in_mysql
query cache
tmp_table_size
27 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Indexes, Queries and
Schemas
InnoDB
– Fast Primary Key Lookups and Range Scans
– Specify a Primary Key
– Keep Primary Keys Small
– Auto-Increment
– Covering Index (All Data to Satisfy Query Is in Index)
MyISAM
– Covering Index
http://dev.mysql.com/doc/refman/5.6/en/slow-query-log.html
http://dev.mysql.com/doc/refman/5.6/en/mysqldumpslow.html
• Indexes used
http://dev.mysql.com/doc/refman/5.6/en/explain-output.htm
http://dev.mysql.com/doc/refman/5.6/en/explain-output.html#explain-extra-information
Service Manager
Enterprise
Dashboard
Repository