How to Optimize the MySQL Server For Performance

Similar documents
Optimizing TYPO3 performance

White Paper. Optimizing the Performance Of MySQL Cluster

DBA Tutorial Kai Voigt Senior MySQL Instructor Sun Microsystems Santa Clara, April 12, 2010

Tushar Joshi Turtle Networks Ltd

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

MySQL: Cloud vs Bare Metal, Performance and Reliability

Percona Server features for OpenStack and Trove Ops

MySQL Cluster Deployment Best Practices

Monitoring MySQL. Kristian Köhntopp

Monitoreo de Bases de Datos

MySQL Storage Engines

Boost SQL Server Performance Buffer Pool Extensions & Delayed Durability

Configuring Apache Derby for Performance and Durability Olav Sandstå

Partitioning under the hood in MySQL 5.5

Encrypting MySQL data at Google. Jonas Oreland and Jeremy Cole

COS 318: Operating Systems

Synchronous multi-master clusters with MySQL: an introduction to Galera

Whitepaper: performance of SqlBulkCopy

Part 3. MySQL DBA I Exam

Tech Tip: Understanding Server Memory Counters

In and Out of the PostgreSQL Shared Buffer Cache

Database Administration with MySQL

Exceptions to the Rule: Essbase Design Principles That Don t Always Apply

Virtuoso and Database Scalability

Cognos Performance Troubleshooting

OVERVIEW Methodology Objectives Terminology Recommended Test Protocol... 3 CLOUD SERVICES VS. DEDICATED HOSTING...

DMS Performance Tuning Guide for SQL Server

Outline. Failure Types

I-Motion SQL Server admin concerns

MySQL Enterprise Backup

VirtualCenter Database Performance for Microsoft SQL Server 2005 VirtualCenter 2.5

One of the database administrators

Wednesday, October 10, 12. Running a High Performance LAMP stack on a $20 Virtual Server

Best practices for operational excellence (SharePoint Server 2010)

MySQL performance in a cloud. Mark Callaghan

MS SQL Performance (Tuning) Best Practices:

Which Database is Better for Zabbix? PostgreSQL vs MySQL. Yoshiharu Mori SRA OSS Inc. Japan

Agenda. Enterprise Application Performance Factors. Current form of Enterprise Applications. Factors to Application Performance.

SharePoint 2010 Performance and Capacity Planning Best Practices

sql server best practice

Auslogics BoostSpeed 5 Manual

Google File System. Web and scalability

External Sorting. Why Sort? 2-Way Sort: Requires 3 Buffers. Chapter 13

IBM DB2: LUW Performance Tuning and Monitoring for Single and Multiple Partition DBs

Oracle Enterprise Manager

DB2 for Linux, UNIX, and Windows Performance Tuning and Monitoring Workshop

Parallel Replication for MySQL in 5 Minutes or Less

About Me: Brent Ozar. Perfmon and Profiler 101

Performance Counters. Microsoft SQL. Technical Data Sheet. Overview:

Top 10 Performance Tips for OBI-EE

PostgreSQL Concurrency Issues

Benchmarking Hadoop & HBase on Violin

MySQL Administration and Management Essentials

Configuring Apache Derby for Performance and Durability Olav Sandstå

Geospatial Server Performance Colin Bertram UK User Group Meeting 23-Sep-2014

Enterprise Edition Scalability. ecommerce Framework Built to Scale Reading Time: 10 minutes

VERITAS Database Edition for Oracle on HP-UX 11i. Performance Report

Windows NT File System. Outline. Hardware Basics. Ausgewählte Betriebssysteme Institut Betriebssysteme Fakultät Informatik

Deploying MySQL with the Oracle ZFS Storage Appliance

Together with SAP MaxDB database tools, you can use third-party backup tools to backup and restore data. You can use third-party backup tools for the

Improve Business Productivity and User Experience with a SanDisk Powered SQL Server 2014 In-Memory OLTP Database

OLTP Meets Bigdata, Challenges, Options, and Future Saibabu Devabhaktuni

Running a Workflow on a PowerCenter Grid

Comparing SQL and NOSQL databases

Enterprise Performance Tuning: Best Practices with SQL Server 2008 Analysis Services. By Ajay Goyal Consultant Scalability Experts, Inc.

Outline. Windows NT File System. Hardware Basics. Win2K File System Formats. NTFS Cluster Sizes NTFS

Dynamics NAV/SQL Server Configuration Recommendations

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

Dave Stokes MySQL Community Manager

File Systems Management and Examples

SQL Server Transaction Log from A to Z

PERFORMANCE TUNING FOR PEOPLESOFT APPLICATIONS

Best Practices for Using MySQL in the Cloud

WITH A FUSION POWERED SQL SERVER 2014 IN-MEMORY OLTP DATABASE

The 5-minute SQL Server Health Check

MySQL Enterprise Backup User's Guide (Version 3.5.4)

Setting Up Specify to use a Shared Workstation as a Database Server

NIMSOFT SLM DATABASE

PGCon PostgreSQL Performance Pitfalls

Enhancing SQL Server Performance

Windows Server Performance Monitoring

Introduction. Part I: Finding Bottlenecks when Something s Wrong. Chapter 1: Performance Tuning 3

Table of Contents. Foreword... xv. Preface... xvii

Oracle Database 11 g Performance Tuning. Recipes. Sam R. Alapati Darl Kuhn Bill Padfield. Apress*

Response Time Analysis

Getting Started with SandStorm NoSQL Benchmark

Agenda. SSIS - enterprise ready ETL

Distribution One Server Requirements

Java DB Performance. Olav Sandstå Sun Microsystems, Trondheim, Norway Submission ID: 860

Cleaning Up Your Outlook Mailbox and Keeping It That Way ;-) Mailbox Cleanup. Quicklinks >>

Azure VM Performance Considerations Running SQL Server

A Survey of Shared File Systems

SQL Server Business Intelligence on HP ProLiant DL785 Server

In this session, we use the table ZZTELE with approx. 115,000 records for the examples. The primary key is defined on the columns NAME,VORNAME,STR

W I S E. SQL Server 2008/2008 R2 Advanced DBA Performance & WISE LTD.

ERserver. iseries. Work management

Performance and Tuning Guide. SAP Sybase IQ 16.0

Using MySQL for Big Data Advantage Integrate for Insight Sastry Vedantam

MAGENTO HOSTING Progressive Server Performance Improvements

Transcription:

1 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12

MySQL Server Performance Tuning 101 Ligaya Turmelle Principle Technical Support Engineer - MySQL @lig ligaya.turmelle@oracle.com https://joind.in/10284 The basics of tuning some of the settings of the MySQL server. We will be covering some of the most common areas you should consider. Who is on 5.6? 5.5? 5.1? 5.0? lower?

THE FOLLOWING IS INTENDED TO OUTLINE OUR GENERAL PRODUCT DIRECTION. IT IS INTENDED FOR INFORMATION PURPOSES ONLY, AND MAY NOT BE INCORPORATED INTO ANY CONTRACT. IT IS NOT A COMMITMENT TO DELIVER ANY MATERIAL, CODE, OR FUNCTIONALITY, AND SHOULD NOT BE RELIED UPON IN MAKING PURCHASING DECISIONS. THE DEVELOPMENT, RELEASE, AND TIMING OF ANY FEATURES OR FUNCTIONALITY DESCRIBED FOR ORACLE'S PRODUCTS REMAINS AT THE SOLE DISCRETION OF ORACLE. 3 Copyright 2013, Oracle and/or its affiliates. All rights reserved. safe harbor - basically if I tell you about any upcoming products it is for informational purposes only. Oracle makes no guarantee.

MySQL in a Nutshell Worlds most popular open source database M of LAMP Main Site: mysql.com Developer Zone: dev.mysql.com OR mysql.org Downloads and Labs Manuals and Bugs Forums and Worklogs 4 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Laying the Foundation 5 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Step 0 The Server OS Network Filesystem 6 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Storage, swappiness, scheduler

Step 0 The MySQL Server Optimize the queries Database Schema 7 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Slow query log, EXPLAIN, Indexing strategies

Step 0 General No easy answers Benchmark and test Under allocate 8 Copyright 2013, Oracle and/or its affiliates. All rights reserved. This is a soft skill with no absolute answers Change 1 thing at a time Under allocate rather then over allocate or you swap There is such a thing as over-tuning the system

MySQL and Memory Global Server Start Large Values Allocated Once Per Connection As Needed Small Values Allocated 0-N Times Global Memory + (Max Connections * Session Buffers) 9 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Generally speaking

Current Settings mysql> SHOW GLOBAL VARIABLES; mysql> SHOW GLOBAL VARIABLES; +--------------------------------------------+------------------ Variable_name Value +--------------------------------------------+------------------ auto_increment_increment 1 auto_increment_offset 1 autocommit ON automatic_sp_privileges ON back_log 80 basedir /usr big_tables OFF bind_address * binlog_cache_size 32768 binlog_checksum CRC32 binlog_direct_non_transactional_updates OFF binlog_format STATEMENT binlog_max_flush_queue_time 0 binlog_order_commits ON 10 Copyright 2013, Oracle and/or its affiliates. All rights reserved. What are the current settings for the server?

Current Settings my.cnf / my.ini [client] socket = /var/run/mysqld/mysql.sock [mysqld] # These settings are for this specific box. server-id = 1 log-bin = /var/lib/mysql/binlogs/xxxxxxxx-bin pid-file = /var/run/mysqld/mysql.pid socket = /var/run/mysqld/mysql.sock performance_schema max_connections = 200 # The ft_min_word_len is set to 3 instead of the default # 3 letter acronyms in the tables with full text ft_min_word_len = 3 11 Copyright 2013, Oracle and/or its affiliates. All rights reserved. everything else

Anything Else? RAM? Dedicated? 32 or 64 bit OS? 32 or 64 bit MySQL? Workload? Storage Engines? 12 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 32 bit addressing limit read/write heavy? short or report queries Mostly InnoDB? MyISAM? Memory? Etc.

Current Status mysql> SHOW GLOBAL STATUS; mysql> show global status; +--------------------------------------+---------------+ Variable_name Value +--------------------------------------+---------------+ Aborted_clients 9363 Aborted_connects 15925 Binlog_cache_disk_use 15684 Binlog_cache_use 272758675 Bytes_received 1219816389366 Bytes_sent 5227022143540 Com_admin_commands 12803263 Com_assign_to_keycache 0 Com_alter_db 0 Com_alter_db_upgrade 0 Com_alter_event 0 13 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Counters - what is done, not what we think is done. Issued twice to find the Delta. Ok during normal operations but best during peak times.

DANGER - Math Ahead! 14 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Finding the Delta Uptime - seconds Ex: 8249391 sec = ~2291.5 hrs = ~95.5 days Find your rate of change 15 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Example 16 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Time to Start 17 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

GENERAL INFO 18 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

COM_* Counters Each command Used to calculate the Delta Com_select 1530076294 Com_set_option 18004985 Com_signal 0 Com_show_authors 0 Com_show_binlog_events 0 Com_show_binlogs 27498 Com_show_charsets 1 Com_show_collations 39 Com_show_contributors 0 Com_show_create_db 3 Com_show_create_event 0 Com_show_create_func 1120 Com_show_create_proc 14499 Com_show_create_table 183538 Com_show_create_trigger 0 19 Copyright 2013, Oracle and/or its affiliates. All rights reserved. What you are actually doing.

Et Al. Connections Queries Questions Slow_queries Sort_merge_passes 20 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Connections - # of attempts to connect - successful or not Queries - # of statements executed - including stored procedures Questions - # of statements sent to the server by clients and executed Slow_queries - # of queries that took longer then long_query_time sec to run Sort_merge_passes - # of merge passes that sort algorithm had to do

INNODB BASICS 21 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Starting in 5.5 this is the default storage engine

How is InnoDB doing? Space Innodb_buffer_pool_pages_data Innodb_buffer_pool_pages_total Innodb_buffer_pool_pages_free 22 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Pages data number of pages containing data (clean and dirty) - Pages total total size in pages (innodb_page_size compiled in, default is 16KB) - Pages_free some are fine but if you see a lot for a while, you over allocated - Dirty page = a page that has changes in the buffer that has been saved to the log files

How is InnoDB doing? Efficiency Innodb_buffer_pool_read_requests Innodb_buffer_pool_reads Formula: 1 - (Innodb_buffer_pool_read / Innodb_buffer_pool_read_requests) = buffer pool hit ratio 23 Copyright 2013, Oracle and/or its affiliates. All rights reserved. reads - reads from disk read_requests - disk or memory

innodb_buffer_pool_size Global Caches data and indexes Larger values reduces IO Self-contained 80% max 24 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Size in bytes - InnoDB uses clustered indexes remember - Larger the value the more it acts like an in-memory database. - Handles and buffers *everything* for itself - Setting it too high can lead to swap === bad

innodb_log_file_size Size of file on disk Larger the file, the less checkpoint activity Size for each log file Max combined log file size 4G <= 5.5 5.6 = 512GB Larger the log file longer recover time 25 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Less checkpoint activity means less IO - Typically there are 2 log files in a log group (innodb_log_files_in_group) - crash recovery code was optimized in 5.5. So the recovery time will be significantly lower in 5.5 then in 5.1. - 5.5 Start test using the full 4G and modify as needed for your requirements and limitations.

innodb_log_buffer_size Buffer for writing to log files on disk Large transactions? Yes - increasing may help with IO Default is 8MB 26 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - If you have large transactions, try to have them fit in here. This reduces the need to write the log to disk before the transactions commit.

innodb_file_per_table.ibd files Default: Off <= 5.6.5 > On Easier to reclaim space TRUNCATE for a table is faster Can monitor table size at the file system Can store specific tables on different storage devices 27 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - for each newly created table the data and indexes will be placed in a separate ibd file rather then in the shared tablespace - reclaiming space from the shared tablespace is not trivial. - reasons for separate devices: IO Optimization, space management, backup purposes

MyISAM 28 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

How is MyISAM doing? Space Key_blocks_unused Formula: key_buffer_size - (Key_blocks_unused * key_cache_block_size) = amount actually in use Key_blocks_used High water mark 29 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Block size can be found in key_cache_block_size - Key_blocks_used indicates the max number of blocks that have ever been in use at one time.

How is MyISAM doing? Efficiency Key_read_requests Key_reads Formula: Key_reads/Key_read_requests = key cache miss rate Key_write_requests Key_writes 30 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Key_read_requests requests to read a key block - Key_reads number of physical reads from disk. Large value may mean your key_buffer_size is too small * Key cache miss rate the lower the value, the better - Key_write_requests # of requests to write a key block - Key_writes - # of physical writes of a key block to disk

How is MyISAM doing? Locking Table_locks_immediate Table_locks_waited 31 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - MyISAM uses table level locking. That means that every time you have to change it, the whole table will be locked for the duration. (Yes - concurrent inserts but that only works under specific circumstances (If a MyISAM table has no holes in the data file (deleted rows in the middle), an INSERT statement can be executed to add rows to the end of the table at the same time that SELECT statements are reading rows from the table.)) - Want to watch Table_locks_waited since this iterates every time you had to wait to get a table lock. If you have high values for this, and you do not use the MyISAM specific features, you may want to consider changing to another storage engine for better concurrency.

key_buffer_size AKA key cache Global Index blocks only 25% - maybe 32 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - The index blocks are buffered and shared by all threads. - MyISAM uses the OS file caching system to hold the data files. This means that we have to leave space for the OS file system otherwise we can start swapping. And swapping can be bad with MySQL. - For this reason, on a dedicated machine heavy on MyISAM, 25% of RAM is a place to start. Notes: - The maximum size is 4G for each key cache. - You can have more then one key cache see the manual for more information on that.

QUERY CACHE 33 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Ask if people understand how the query cache works. If they do not understand - explain it. Also explain that this can become a bottle neck for performance with high concurrency since it is single threaded.

How is the QC doing? Qcache_total_blocks Qcache_free_blocks Not what you think Qcache_lowmem_prunes 34 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Free_blocks think this would be a good thing, but isn t. The higher the value, the greater the fragmentation in the query cache. * As Qcache_free_blocks approaches Qcache_total_blocks/2 the more severe the fragmentation * To defragment the query cache use the FLUSH QUERY CACHE statement - lowmem prunes number of queries deleted from the QC because of low memory

How is the QC doing? Qcache_hits Qcache_inserts Qcache_not_cached Qcache_queries_in_cache 35 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

QC Data into Info Hit rate Higher the better Formula: Qcache_hits / (Qcache_hits + Com_select) = Query Cache Hit Rate Invalidating queries Bigger the diff - the better Comparison: Qcache_inserts << Com_select 36 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Keep in mind warming up the cache

- Minor side note - http://bugs.mysql.com/bug.php?id=38551 (5.1) Query cache mutex still acquired even with query cache size set to 0 query_cache_size Global Allocated all at once Default is disabled Default size 0 < 5.6.8 => 1M 37 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - The default of 0 disables the query cache. Generally speaking it is recommended that you start with the query cache off, and only if you think it can help you, do you turn it on. Be sure to check the performance of the system when you turn it on to verify that it does increase. There is potential for substantial performance improvement, but do not assume that it will happen. With some query cache configurations or server workloads, it is possible to see a performance decrease. Before 5.6.8 default size was 0 - now 1M with query_cache_type=0.

query_cache_type Global - but can be session 3 options 0 Off 1 On 2 On Demand Default: 1 < 5.6.8 => 0 38 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 0 - Do not cache results or pull results from the QC 1 - Cache all you can unless told not to with SQL_NO_CACHE 2 - Cache only those queries that have SQL_CACHE Turning it Off (0) - now saves a significant amount of overhead since it will no longer try to acquire the query cache mutex at all. However that means you can not turn on the query cache at runtime (dynamically).

Gotcha! 39 Copyright 2013, Oracle and/or its affiliates. All rights reserved. The query cache size will still be allocated when the server starts up even if you have the type set to 0.

THREADS AND TABLE CACHE 40 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Threads Threads == Connection Thread Cache Threads_cached Threads_connected Threads_created Formula: Threads_created /Connections = Thread cache miss rate 41 Copyright 2013, Oracle and/or its affiliates. All rights reserved. This is more for those using an older system. - In regards to this discussion that is. - Thread cache * threads can be expensive to create and destroy for every connection. - explain how the thread cache works. (starts out empty and as new connections are made it checks the cache to see if one is there. If so it uses it. If not it makes a new thread. When done it puts the threads back into the thread cache until it has its max value. Watch Threads_created if large consider increasing the thread_cache

thread_cache_size Global but grows as needed Number to be cached until needed May increase performance with lots of new connections or may not Formula: 100 - ((Threads_created/Connections) * 100) = Thread cache efficiency 42 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Because of modern thread implementations be sure to test to see if you get any improvement.

Table_cache table_cache <= 5.1.3 > table_open_cache Expands as needed Number of open tables for all connections Watch Opened_tables 43 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Similar to OS level file descriptors. Increasing this value may mean you have to increase the number of file descriptors MySQL requires. - If Opened_tables is constantly increasing and you are *not* using FLUSH TABLES often consider increasing this. - related to max_connections (For example, for 200 concurrent running connections, specify a table cache size of at least 200 * N, where N is the maximum number of tables per join in any of the queries which you execute. You must also reserve some extra file descriptors for temporary tables and files.) http://dev.mysql.com/doc/refman/5.6/en/table-cache.html

If you want to know more about the INNODB STATUS output be sure to check out the manual and the mysql performance blog INNODB NOT SO BASICS 44 Copyright 2013, Oracle and/or its affiliates. All rights reserved. InnoDB takes care of most things automatically. So usually you do not need to tune these setting until there is a problem. Unfortunately working with these settings is not as straightforward as watching the output of SHOW GLOBAL STATUS. Instead you would need to watch the output of SHOW ENGINE INNODB STATUS. To be perfectly honest - reading and understanding the output of SHOW ENGINE INNODB STATUS is a complex enough subject for a talk all by itself and I just do not have the time to cover it. That being said, I still think you should know about these.

innodb_buffer_pool_instances 5.6 Problem: contention for the buffer pool resources For systems with multi-gb buffer pools Total buffer pool size divided between this many instances Each instance manages its own resources has its own mutex 45 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Problem seen in INNODB STATUS in the SEMAPHORE section - Generally each instance should not be less then 1G - Allows for parallelism of the buffer pool resources - Access may not be evenly balanced across buffer pools.

innodb_stats_persistent 5.6 Problem: changing execution plans Index statistics from ANALYZE TABLE stored on disk Results in stabler and usually better execution plans Periodic ANALYZE TABLE should be run if set 46 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Turn on if you have queries that change to suboptimal execution plans - statistics stay consistent until next ANALYZE TABLE - Once a week or month is probably sufficient for tables that have fairly stable or gradually changing sizes. For tables that are small or have very rapidly changing contents more frequent will be beneficial.

innodb_thread_concurrency Max number of OS threads concurrently inside InnoDB 5.5+: Default 0 - unlimited Problem: InnoDB thread Log Jam Test a range of values to see what works best 47 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Additional threads placed into wait state in FIFO queue - Think about that - unlimited number of threads trying to access the same finite number or resources. Now add in if you have long running queries holding locks... Eventually even the small fast queries will slow down as they all fight for the resources they need! This is a concurrency issue. - Basic Signs: increasing number of running transactions in InnoDB and server performance degrades. Never stops - but runs really slow - Best value is dependent on your environment and workload

innodb_concurrency_tickets Works with innodb_thread_concurrency Number of free tickets given to a ticket While tickets!= 0 enter and exit InnoDB freely No tickets - back to innodb_thread_concurrency check Long running queries blocking short faster queries Consider increasing 48 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - can help with the log jam - By allowing long running queries extended time in InnoDB, it is more likely they will finish rather then having to go back into the thread_concurrency FIFO queue (while still holding its locks). - Default: 500 <= 5.6.6 > 5000

SESSION LEVEL 49 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - These values should in the global scope be set to a small value since they are used for each session. Only if you have a session that is doing something out of the ordinary should you consider dynamically changing these values. Keep in mind that each query can potentially have 1 N instances of a session level buffer as well (think multiple temp tables), so if you increase these values for a specific session you have to be sure the space is available.

Temporary Tables max_heap_table_size Dynamic Sets maximum size of all MEMORY tables tmp_table_size Dynamic In-memory - MEMORY table Max size of internal in-memory temp tables Becomes on-disk MyISAM table 50 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Other reasons temp tables can automatically go to disk: * BLOB * column in a GROUP BY or DISTINCT clause larger than 512 bytes * any column larger than 512 bytes in the SELECT list, if UNION or UNION ALL is used

sort_buffer_size Dynamic Doing a sort - allocates a buffer this size Helps with ORDER BY and/or GROUP BY Watch Sort_merge_passes 51 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Whole buffer is allocated even if it is not used prior to 5.6.4

read_buffer_size Dynamic Sequential scan - allocates this size for each table scanned caching results of nested queries caching index for sorting with ORDER BY Max: 2GB not normally higher then 8M though 52 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - For each thread that does a sequential scan on a MyISAM table - Sequential scan includes full table scans and ranges This option is also used in the following context for all search engines: For caching the indexes in a temporary file (not a temporary table), when sorting rows for ORDER BY. For bulk insert into partitions. For caching results of nested queries. and in one other storage engine-specific way: to determine the memory block size for MEMORY tables.

read_rnd_buffer_size Dynamic Reading MyISAM rows in arbitrary sequence Large value can potentially improve ORDER BY Max: 2 GB not normally higher then 8M 53 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - to avoid disk seeks - Example of usage reading rows in a sorted order after the key sorting

bulk_insert_buffer_size Dynamic Cache to assist with MyISAM bulk inserts Set to 0 to disable 54 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - Bulk inserts == INSERT SELECT, INSERT VALUES ( ), ( ), ( ), LOAD DATA INFILE when adding data to non-empty tables.

join_buffer_size Use with care Used for plain index scan range index scan joins that do not use indexes - full table scan One buffer for EACH full join between tables 55 Copyright 2013, Oracle and/or its affiliates. All rights reserved. - I am always hesitant to show this slide. I do not want people to think this can be used to help poorly optimized queries. Should be used as a band aid or if adding the appropriate indexes is not possible. Make it very large - and you may have to wait for the the allocation of the memory

Questions? 56 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Thank you for time and attention.

MySQL Server Performance Tuning 101 Ligaya Turmelle Principle Technical Support Engineer - MySQL @lig ligaya.turmelle@oracle.com https://joind.in/10284

58 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12