Successfully reported this slideshow.

Perf Tuning Short

14,317 views

Published on

a slightly shorter and easier to follow presentation on MySQL performance tuning

Published in: Technology

Perf Tuning Short

  1. MySQL Performance Tuning 101 Ligaya Turmelle MySQL Support Engineer ligaya@mysql.com 1
  2. MySQL world's most popular open source database software a key part of LAMP (Linux, Apache, MySQL, PHP / Perl / Python) Site: http://www.mysql.com/ Download: http://dev.mysql.com/downloads/ Online Manual: http://dev.mysql.com/doc/ refman/5.1/en/index.html 2
  3. Before you start 3
  4. Before you start Single greatest gain can be received by optimizing the queries. 3
  5. Before you start Single greatest gain can be received by optimizing the queries. Optimize the underlying system 3
  6. Before you start Single greatest gain can be received by optimizing the queries. Optimize the underlying system Understand there are no hard/fast/exact answers for values. 3
  7. Before you start Single greatest gain can be received by optimizing the queries. Optimize the underlying system Understand there are no hard/fast/exact answers for values. Change one value at a time and benchmark to look for improvement 3
  8. Before you start Single greatest gain can be received by optimizing the queries. Optimize the underlying system Understand there are no hard/fast/exact answers for values. Change one value at a time and benchmark to look for improvement Better to under allocate then over allocate values 3
  9. How we use memory 4
  10. How we use memory 2 Ways - Global and per Connection 4
  11. How we use memory 2 Ways - Global and per Connection Global - Most allocated once when the server starts - can be large 4
  12. How we use memory 2 Ways - Global and per Connection Global - Most allocated once when the server starts - can be large Per Connection - for each connection as needed - should be small 4
  13. How we use memory 2 Ways - Global and per Connection Global - Most allocated once when the server starts - can be large Per Connection - for each connection as needed - should be small Global memory + (max_connections * session buffers) 4
  14. Information 5
  15. Information Current Settings 5
  16. Information Current Settings mysql> SHOW GLOBAL VARIABLES; 5
  17. Information Current Settings mysql> SHOW GLOBAL VARIABLES; Shows the majority of the settings +----------------------------------------------------------------------------------------------------------------------------+ |Variable_name | Value +-----------------------------------------------------------------------------------------------+ | auto_increment_increment | 1 | auto_increment_offset | 1 | automatic_sp_privileges | ON | back_log | 50 | basedir | /Users/ligaya/mysql_installs/mysql-enterprise-gpl-5.0.50sp1-osx10.5-x86/ | binlog_cache_size | 32768 | bulk_insert_buffer_size | 8388608 | character_set_client | latin1 5
  18. Information Current Settings mysql> SHOW GLOBAL VARIABLES; Shows the majority of the settings +----------------------------------------------------------------------------------------------------------------------------+ |Variable_name | Value +-----------------------------------------------------------------------------------------------+ | auto_increment_increment | 1 | auto_increment_offset | 1 | automatic_sp_privileges | ON | back_log | 50 | basedir | /Users/ligaya/mysql_installs/mysql-enterprise-gpl-5.0.50sp1-osx10.5-x86/ | binlog_cache_size | 32768 | bulk_insert_buffer_size | 8388608 | character_set_client | latin1 my.cnf/my.ini 5
  19. Other Information 6
  20. Other Information How much RAM on the machine? 6
  21. Other Information How much RAM on the machine? Is the machine dedicated to MySQL? 6
  22. Other Information How much RAM on the machine? Is the machine dedicated to MySQL? 64 bit processor? 6
  23. Other Information How much RAM on the machine? Is the machine dedicated to MySQL? 64 bit processor? 64 bit MySQL server binary? 6
  24. Server Status 7
  25. Server Status mysql> SHOW GLOBAL STATUS; 7
  26. Server Status mysql> SHOW GLOBAL STATUS; has various counters 7
  27. Server Status mysql> SHOW GLOBAL STATUS; has various counters gives you a feel of what the server is actually doing - not what you *think* it is doing 7
  28. Server Status mysql> SHOW GLOBAL STATUS; has various counters gives you a feel of what the server is actually doing - not what you *think* it is doing issue command twice with time between to get the changes of values over time 7
  29. Example Status +-----------------------------------+-------------+ | Variable_name | Value | +-----------------------------------+-------------+ | Aborted_clients | 6618 | | Aborted_connects | 3957 | | Binlog_cache_disk_use | 0 | | Binlog_cache_use | 0 | | Bytes_received | 1320510015 | | Bytes_sent | 2978960756 | | Com_admin_commands | 32124 | .... | Threads_cached | 0 | | Threads_connected | 1 | | Threads_created | 316771 | | Threads_running | 1 | | Uptime | 1722523 | | Uptime_since_flush_status | 1722523 | +-----------------------------------+-------------+ 8
  30. Finding the delta 9
  31. Finding the delta Uptime - part of status information and is given in seconds 9
  32. Finding the delta Uptime - part of status information and is given in seconds Ex: 1086122 seconds = ~19.9 days = 478.5 hrs 9
  33. Finding the delta Uptime - part of status information and is given in seconds Ex: 1086122 seconds = ~19.9 days = 478.5 hrs helps you calculate the values in a given time frame (high load, average load). 9
  34. Finding the delta Uptime - part of status information and is given in seconds Ex: 1086122 seconds = ~19.9 days = 478.5 hrs helps you calculate the values in a given time frame (high load, average load). Ex: (bytes received[2] – bytes received[1])/ (Uptime[2] – Uptime[1]) 9
  35. Finding the delta Uptime - part of status information and is given in seconds Ex: 1086122 seconds = ~19.9 days = 478.5 hrs helps you calculate the values in a given time frame (high load, average load). Ex: (bytes received[2] – bytes received[1])/ (Uptime[2] – Uptime[1]) (1320582719 - 1320510015 )/(1722729 - 1722523) = 9
  36. Finding the delta Uptime - part of status information and is given in seconds Ex: 1086122 seconds = ~19.9 days = 478.5 hrs helps you calculate the values in a given time frame (high load, average load). Ex: (bytes received[2] – bytes received[1])/ (Uptime[2] – Uptime[1]) (1320582719 - 1320510015 )/(1722729 - 1722523) = 72704 bytes/ 206 sec = 352.9 bytes/sec 9
  37. What is the server doing? 10
  38. What is the server doing? Com_XXXX 10
  39. What is the server doing? Com_XXXX Counter of the number of times XXXX has been executed 10
  40. What is the server doing? Com_XXXX Counter of the number of times XXXX has been executed One status variable for each statement | Com_delete | 78813 | | Com_insert | 100357 | | Com_replace | 3130 | | Com_select | 984292 | | Com_show_tables | 459 | | Com_show_triggers | 898 | | Com_create_table | 1349 | | Com_update | 285105 | 10
  41. What is the server doing? Com_XXXX Counter of the number of times XXXX has been executed One status variable for each statement | Com_delete | 78813 | | Com_insert | 100357 | | Com_replace | 3130 | | Com_select | 984292 | | Com_show_tables | 459 | | Com_show_triggers | 898 | | Com_create_table | 1349 | | Com_update | 285105 | Used with Uptime to find insert/sec or delete/sec 10
  42. What is the server doing (con’t)? 11
  43. What is the server doing (con’t)? Information on your key buffer (MyISAM) 11
  44. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_blocks_unused: 11
  45. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_blocks_unused: number of unused blocks 11
  46. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_blocks_unused: number of unused blocks key_buffer_size - Key_blocks_unused = amount in use 11
  47. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_blocks_unused: number of unused blocks key_buffer_size - Key_blocks_unused = amount in use Key_blocks_used: 11
  48. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_blocks_unused: number of unused blocks key_buffer_size - Key_blocks_unused = amount in use Key_blocks_used: a high-water mark that indicates the maximum number of blocks that have ever been in use at one time. 11
  49. What is the server doing (con’t)? 12
  50. What is the server doing (con’t)? Information on your key buffer (MyISAM) 12
  51. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_read_requests: 12
  52. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_read_requests: number of requests to read a key block from the cache. 12
  53. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_read_requests: number of requests to read a key block from the cache. a cache hit 12
  54. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_read_requests: number of requests to read a key block from the cache. a cache hit Key_reads: 12
  55. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_read_requests: number of requests to read a key block from the cache. a cache hit Key_reads: number of physical reads of a key block from disk. 12
  56. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_read_requests: number of requests to read a key block from the cache. a cache hit Key_reads: number of physical reads of a key block from disk. a cache miss 12
  57. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_read_requests: number of requests to read a key block from the cache. a cache hit Key_reads: number of physical reads of a key block from disk. a cache miss If large, key_buffer_size is probably too small. 12
  58. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_read_requests: number of requests to read a key block from the cache. a cache hit Key_reads: number of physical reads of a key block from disk. a cache miss If large, key_buffer_size is probably too small. cache miss rate = Key_reads/ Key_read_requests. 12
  59. What is the server doing (con’t)? Information on your key buffer (MyISAM) Key_read_requests: number of requests to read a key block from the cache. a cache hit Key_reads: number of physical reads of a key block from disk. a cache miss If large, key_buffer_size is probably too small. cache miss rate = Key_reads/ Key_read_requests. Key buffer efficiency: 1 – cache miss rate 12
  60. key_buffer_size 13
  61. key_buffer_size Global variable 13
  62. key_buffer_size Global variable the buffer used for MyISAM *index blocks*. 13
  63. key_buffer_size Global variable the buffer used for MyISAM *index blocks*. Index blocks are buffered and shared by all threads. 13
  64. key_buffer_size Global variable the buffer used for MyISAM *index blocks*. Index blocks are buffered and shared by all threads. The maximum allowable setting 4GB on 32-bit platforms. after 5.0.52 on 64-bit systems - 4GB+ 13
  65. key_buffer_size Global variable the buffer used for MyISAM *index blocks*. Index blocks are buffered and shared by all threads. The maximum allowable setting 4GB on 32-bit platforms. after 5.0.52 on 64-bit systems - 4GB+ dedicated machine -25% of total memory is quite common. 13
  66. key_buffer_size Global variable the buffer used for MyISAM *index blocks*. Index blocks are buffered and shared by all threads. The maximum allowable setting 4GB on 32-bit platforms. after 5.0.52 on 64-bit systems - 4GB+ dedicated machine -25% of total memory is quite common. uses the OS file cache to cache the files 13
  67. key_buffer_size Global variable the buffer used for MyISAM *index blocks*. Index blocks are buffered and shared by all threads. The maximum allowable setting 4GB on 32-bit platforms. after 5.0.52 on 64-bit systems - 4GB+ dedicated machine -25% of total memory is quite common. uses the OS file cache to cache the files too high == paging === bad 13
  68. What is the server doing (con’t)? 14
  69. What is the server doing (con’t)? Table_locks_immediate: # of table locks granted immediately to MyISAM tables. 14
  70. What is the server doing (con’t)? Table_locks_immediate: # of table locks granted immediately to MyISAM tables. Table_locks_waited: # of times we had to wait to get a table lock for MyISAM tables 14
  71. What is the server doing (con’t)? Table_locks_immediate: # of table locks granted immediately to MyISAM tables. Table_locks_waited: # of times we had to wait to get a table lock for MyISAM tables If the value is high - you may want to consider changing storage engines. 14
  72. What is the server doing (con’t)? 15
  73. What is the server doing (con’t)? Innodb_* 15
  74. What is the server doing (con’t)? Innodb_* Has various information about the InnoDB tablespace 15
  75. What is the server doing (con’t)? Innodb_* Has various information about the InnoDB tablespace Innodb_buffer_pool_pages_data: number of pages containing data (dirty or clean). 15
  76. What is the server doing (con’t)? Innodb_* Has various information about the InnoDB tablespace Innodb_buffer_pool_pages_data: number of pages containing data (dirty or clean). Innodb_buffer_pool_pages_free: number of free pages. 15
  77. What is the server doing (con’t)? Innodb_* Has various information about the InnoDB tablespace Innodb_buffer_pool_pages_data: number of pages containing data (dirty or clean). Innodb_buffer_pool_pages_free: number of free pages. Innodb_buffer_pool_pages_total: The total size of the buffer pool, in pages. 15
  78. What is the server doing (con’t)? Innodb_* Has various information about the InnoDB tablespace Innodb_buffer_pool_pages_data: number of pages containing data (dirty or clean). Innodb_buffer_pool_pages_free: number of free pages. Innodb_buffer_pool_pages_total: The total size of the buffer pool, in pages. Innodb_buffer_pool_wait_free: counts instances of waiting for pages to be flushed. Should be small value. 15
  79. innodb_buffer_pool_size 16
  80. innodb_buffer_pool_size Global variable 16
  81. innodb_buffer_pool_size Global variable size in bytes 16
  82. innodb_buffer_pool_size Global variable size in bytes used to cache data and indexes of tables. (Clustered indexes - remember) 16
  83. innodb_buffer_pool_size Global variable size in bytes used to cache data and indexes of tables. (Clustered indexes - remember) The larger you set this value, the less disk I/O is needed to access data in tables. 16
  84. innodb_buffer_pool_size Global variable size in bytes used to cache data and indexes of tables. (Clustered indexes - remember) The larger you set this value, the less disk I/O is needed to access data in tables. On a dedicated database server - up to 80% of the machine physical memory size. 16
  85. innodb_buffer_pool_size Global variable size in bytes used to cache data and indexes of tables. (Clustered indexes - remember) The larger you set this value, the less disk I/O is needed to access data in tables. On a dedicated database server - up to 80% of the machine physical memory size. Buffers everything itself. 16
  86. innodb_buffer_pool_size Global variable size in bytes used to cache data and indexes of tables. (Clustered indexes - remember) The larger you set this value, the less disk I/O is needed to access data in tables. On a dedicated database server - up to 80% of the machine physical memory size. Buffers everything itself. do not set it too large - might cause paging in the operating system. 16
  87. innodb_log_file_size 17
  88. innodb_log_file_size Global variable 17
  89. innodb_log_file_size Global variable size in bytes of *each* log file in a log group. 17
  90. innodb_log_file_size Global variable size in bytes of *each* log file in a log group. Balancing act larger the value, the less checkpoint flush activity - less disk I/O larger the log files - longer the crash recovery time 17
  91. innodb_log_file_size Global variable size in bytes of *each* log file in a log group. Balancing act larger the value, the less checkpoint flush activity - less disk I/O larger the log files - longer the crash recovery time Sensible values range: 1MB to 1/N-th of the size of the buffer pool N is the number of log files in the group (innodb_log_files_in_group - usually 2). 17
  92. innodb_log_file_size Global variable size in bytes of *each* log file in a log group. Balancing act larger the value, the less checkpoint flush activity - less disk I/O larger the log files - longer the crash recovery time Sensible values range: 1MB to 1/N-th of the size of the buffer pool N is the number of log files in the group (innodb_log_files_in_group - usually 2). combined size of log files must be less than 4GB 17
  93. What is the server doing (con’t)? 18
  94. What is the server doing (con’t)? Query Cache Information 18
  95. What is the server doing (con’t)? Query Cache Information Qcache_total_blocks: total number of blocks in the query cache. 18
  96. What is the server doing (con’t)? Query Cache Information Qcache_total_blocks: total number of blocks in the query cache. Qcache_free_blocks: number of free memory blocks. Can indicate a problem with fragmentation. 18
  97. What is the server doing (con’t)? Query Cache Information Qcache_total_blocks: total number of blocks in the query cache. Qcache_free_blocks: number of free memory blocks. Can indicate a problem with fragmentation. Qcache_hits: number of query cache hits. 18
  98. What is the server doing (con’t)? Query Cache Information Qcache_total_blocks: total number of blocks in the query cache. Qcache_free_blocks: number of free memory blocks. Can indicate a problem with fragmentation. Qcache_hits: number of query cache hits. Qcache_inserts: number of queries added to the query cache. 18
  99. What is the server doing (con’t) Query Cache (con’t) Qcache_not_cached: number of non-cached queries (not cacheable, or not cached due to the query_cache_type setting). Qcache_queries_in_cache: number of queries registered in the query cache. Qcache_lowmem_prunes: number of queries that were deleted from the query cache because of low memory. 19
  100. What is the server doing (con’t)? 20
  101. What is the server doing (con’t)? Turning the Query cache counters into information 20
  102. What is the server doing (con’t)? Turning the Query cache counters into information One quick and easy way to determine if you benefit from using the query cache – Query Cache Hit Rate QC Hit Rate = Qcache_hits/(Qcache_hits +Com_select) 20
  103. What is the server doing (con’t)? Turning the Query cache counters into information One quick and easy way to determine if you benefit from using the query cache – Query Cache Hit Rate QC Hit Rate = Qcache_hits/(Qcache_hits +Com_select) Also check to see how often you are invalidating the queries in the cache. Qcache_inserts vs Com_select Want Qcache_inserts << Com_select - bigger the difference, the better 20
  104. What is the server doing (con’t)? Turning the Query cache counters into information One quick and easy way to determine if you benefit from using the query cache – Query Cache Hit Rate QC Hit Rate = Qcache_hits/(Qcache_hits +Com_select) Also check to see how often you are invalidating the queries in the cache. Qcache_inserts vs Com_select Want Qcache_inserts << Com_select - bigger the difference, the better Note: keep in mind warming up the cache 20
  105. query_cache_size 21
  106. query_cache_size Global variable 21
  107. query_cache_size Global variable The amount of memory allocated for caching query results. 21
  108. query_cache_size Global variable The amount of memory allocated for caching query results. default value is 0, which disables the query cache. 21
  109. query_cache_size Global variable The amount of memory allocated for caching query results. default value is 0, which disables the query cache. allowable values are multiples of 1024; other values are rounded down to the nearest multiple. 21
  110. query_cache_type 22
  111. query_cache_type Global variable but can be set at the session level 22
  112. query_cache_type Global variable but can be set at the session level 3 options 22
  113. query_cache_type Global variable but can be set at the session level 3 options 0 (Off) - Don't cache results in or retrieve results from the query cache. 22
  114. query_cache_type Global variable but can be set at the session level 3 options 0 (Off) - Don't cache results in or retrieve results from the query cache. 1 (On) - Cache all cacheable query results except - SELECT SQL_NO_CACHE. Default 22
  115. query_cache_type Global variable but can be set at the session level 3 options 0 (Off) - Don't cache results in or retrieve results from the query cache. 1 (On) - Cache all cacheable query results except - SELECT SQL_NO_CACHE. Default 2 (Demand) - Cache results only for cacheable queries that begin with SELECT SQL_CACHE 22
  116. query_cache_type Global variable but can be set at the session level 3 options 0 (Off) - Don't cache results in or retrieve results from the query cache. 1 (On) - Cache all cacheable query results except - SELECT SQL_NO_CACHE. Default 2 (Demand) - Cache results only for cacheable queries that begin with SELECT SQL_CACHE Note that the query_cache_size of memory is allocated even if query_cache_type is set to 0. 22
  117. What is the server doing (con’t)? 23
  118. What is the server doing (con’t)? Threads 23
  119. What is the server doing (con’t)? Threads Threads_cached: # of threads in the thread cache. 23
  120. What is the server doing (con’t)? Threads Threads_cached: # of threads in the thread cache. Threads_connected: # of currently open connections. 23
  121. What is the server doing (con’t)? Threads Threads_cached: # of threads in the thread cache. Threads_connected: # of currently open connections. Threads_created: # of threads created to handle connections. 23
  122. What is the server doing (con’t)? Threads Threads_cached: # of threads in the thread cache. Threads_connected: # of currently open connections. Threads_created: # of threads created to handle connections. If Threads_created is “big”, you may want to increase the thread_cache_size value. 23
  123. What is the server doing (con’t)? Threads Threads_cached: # of threads in the thread cache. Threads_connected: # of currently open connections. Threads_created: # of threads created to handle connections. If Threads_created is “big”, you may want to increase the thread_cache_size value. thread cache miss rate = Threads_created/ Connections. 23
  124. thread_cache_size 24
  125. thread_cache_size Global variable but it grows as needed. 24
  126. thread_cache_size Global variable but it grows as needed. threads to be cached for reuse. 24
  127. thread_cache_size Global variable but it grows as needed. threads to be cached for reuse. When a client disconnects, client's threads are put in the cache until it is full. 24
  128. thread_cache_size Global variable but it grows as needed. threads to be cached for reuse. When a client disconnects, client's threads are put in the cache until it is full. Requests for threads are satisfied by reusing threads taken from the cache. Only when the cache is empty is a new thread created. 24
  129. thread_cache_size Global variable but it grows as needed. threads to be cached for reuse. When a client disconnects, client's threads are put in the cache until it is full. Requests for threads are satisfied by reusing threads taken from the cache. Only when the cache is empty is a new thread created. increase to improve performance if you have a lot of new connections. 24
  130. thread_cache_size Global variable but it grows as needed. threads to be cached for reuse. When a client disconnects, client's threads are put in the cache until it is full. Requests for threads are satisfied by reusing threads taken from the cache. Only when the cache is empty is a new thread created. increase to improve performance if you have a lot of new connections. May not provide a notable performance improvement if you have a good thread implementation. 24
  131. thread_cache_size Global variable but it grows as needed. threads to be cached for reuse. When a client disconnects, client's threads are put in the cache until it is full. Requests for threads are satisfied by reusing threads taken from the cache. Only when the cache is empty is a new thread created. increase to improve performance if you have a lot of new connections. May not provide a notable performance improvement if you have a good thread implementation. (100-((Threads_created / Connections)*100) = thread cache efficiency 24
  132. What is the server doing (con’t)? 25
  133. What is the server doing (con’t)? General Information counters of importance 25
  134. What is the server doing (con’t)? General Information counters of importance Connections: # of connection attempts (successful or not) 25
  135. What is the server doing (con’t)? General Information counters of importance Connections: # of connection attempts (successful or not) Queries: # of statements executed including statements executed within stored programs. added 5.0.76. 25
  136. What is the server doing (con’t)? General Information counters of importance Connections: # of connection attempts (successful or not) Queries: # of statements executed including statements executed within stored programs. added 5.0.76. Questions: # of statements sent to the server by clients and executed by the server. As of 5.0.72 25
  137. What is the server doing (con’t)? General Information counters of importance Connections: # of connection attempts (successful or not) Queries: # of statements executed including statements executed within stored programs. added 5.0.76. Questions: # of statements sent to the server by clients and executed by the server. As of 5.0.72 Slow_queries: # of queries that have taken more than long_query_time seconds. 25
  138. What is the server doing (con’t)? General Information counters of importance Connections: # of connection attempts (successful or not) Queries: # of statements executed including statements executed within stored programs. added 5.0.76. Questions: # of statements sent to the server by clients and executed by the server. As of 5.0.72 Slow_queries: # of queries that have taken more than long_query_time seconds. Sort_merge_passes: # of merge passes that the sort algorithm has had to do. If large, consider increasing the value of the sort_buffer_size system variable. 25
  139. Another Global Variable for Tweeking 26
  140. Another Global Variable for Tweeking table_cache: 26
  141. Another Global Variable for Tweeking table_cache: The number of open tables for all threads. 26
  142. Another Global Variable for Tweeking table_cache: The number of open tables for all threads. Increasing this value increases the number of file descriptors that mysqld requires. 26
  143. Another Global Variable for Tweeking table_cache: The number of open tables for all threads. Increasing this value increases the number of file descriptors that mysqld requires. If Opened_tables is constantly increasing and you don't do FLUSH TABLES often - then you should increase the value of the table_cache variable. 26
  144. Another Global Variable for Tweeking table_cache: The number of open tables for all threads. Increasing this value increases the number of file descriptors that mysqld requires. If Opened_tables is constantly increasing and you don't do FLUSH TABLES often - then you should increase the value of the table_cache variable. Global variable that expands as needed 26
  145. Per connection variables available for tweeking 27
  146. Per connection variables available for tweeking max_heap_table_size: 27
  147. Per connection variables available for tweeking max_heap_table_size: sets the maximum size to which MEMORY tables are allowed to grow. 27
  148. Per connection variables available for tweeking max_heap_table_size: sets the maximum size to which MEMORY tables are allowed to grow. Dynamic variable - can be set per session 27
  149. Per connection variables available for tweeking max_heap_table_size: sets the maximum size to which MEMORY tables are allowed to grow. Dynamic variable - can be set per session tmp_table_size: 27
  150. Per connection variables available for tweeking max_heap_table_size: sets the maximum size to which MEMORY tables are allowed to grow. Dynamic variable - can be set per session tmp_table_size: Dynamic variable - can be set per session 27
  151. Per connection variables available for tweeking max_heap_table_size: sets the maximum size to which MEMORY tables are allowed to grow. Dynamic variable - can be set per session tmp_table_size: Dynamic variable - can be set per session maximum size of internal in-memory temporary tables. actual limit is determined as the smaller of max_heap_table_size and tmp_table_size. 27
  152. Per connection variables available for tweeking max_heap_table_size: sets the maximum size to which MEMORY tables are allowed to grow. Dynamic variable - can be set per session tmp_table_size: Dynamic variable - can be set per session maximum size of internal in-memory temporary tables. actual limit is determined as the smaller of max_heap_table_size and tmp_table_size. If in-memory temporary table exceeds the limit - MySQL automatically converts it to an on-disk MyISAM table. 27
  153. Per connection variables available for tweeking 28
  154. Per connection variables available for tweeking read_buffer_size: 28
  155. Per connection variables available for tweeking read_buffer_size: Dynamic variable - can be set per session 28
  156. Per connection variables available for tweeking read_buffer_size: Dynamic variable - can be set per session Each thread that does a sequential scan - allocates a buffer of this size (in bytes) for each *table* it scans. 28
  157. Per connection variables available for tweeking read_buffer_size: Dynamic variable - can be set per session Each thread that does a sequential scan - allocates a buffer of this size (in bytes) for each *table* it scans. If you do many sequential scans, you might want to increase this value. 28
  158. Per connection variables available for tweeking read_buffer_size: Dynamic variable - can be set per session Each thread that does a sequential scan - allocates a buffer of this size (in bytes) for each *table* it scans. If you do many sequential scans, you might want to increase this value. value of this variable should be a multiple of 4KB. 28
  159. Per connection variables available for tweeking read_buffer_size: Dynamic variable - can be set per session Each thread that does a sequential scan - allocates a buffer of this size (in bytes) for each *table* it scans. If you do many sequential scans, you might want to increase this value. value of this variable should be a multiple of 4KB. maximum allowable setting is 2GB do not normally recommend having it higher then 8M. 28
  160. Per connection variables available for tweeking 29
  161. Per connection variables available for tweeking read_rnd_buffer_size: 29
  162. Per connection variables available for tweeking read_rnd_buffer_size: Dynamic variable - can be set per session 29
  163. Per connection variables available for tweeking read_rnd_buffer_size: Dynamic variable - can be set per session for reading rows in sorted order following a key-sorting operation. designed to avoid disk seeks. 29
  164. Per connection variables available for tweeking read_rnd_buffer_size: Dynamic variable - can be set per session for reading rows in sorted order following a key-sorting operation. designed to avoid disk seeks. a large value can improve ORDER BY performance. 29
  165. Per connection variables available for tweeking read_rnd_buffer_size: Dynamic variable - can be set per session for reading rows in sorted order following a key-sorting operation. designed to avoid disk seeks. a large value can improve ORDER BY performance. maximum allowable setting is 2GB do not normally recommend having it higher then 8M. 29
  166. Per connection variables available for tweeking 30
  167. Per connection variables available for tweeking sort_buffer_size: 30
  168. Per connection variables available for tweeking sort_buffer_size: Dynamic variable - can be set per session 30
  169. Per connection variables available for tweeking sort_buffer_size: Dynamic variable - can be set per session Each thread that needs to do a sort allocates a buffer of this size. 30
  170. Per connection variables available for tweeking sort_buffer_size: Dynamic variable - can be set per session Each thread that needs to do a sort allocates a buffer of this size. Increase this value for faster ORDER BY or GROUP BY operations. 30
  171. Per connection variables available for tweeking 31
  172. Per connection variables available for tweeking bulk_insert_buffer_size: 31
  173. Per connection variables available for tweeking bulk_insert_buffer_size: Dynamic variable - can be set per session 31
  174. Per connection variables available for tweeking bulk_insert_buffer_size: Dynamic variable - can be set per session Cache to make bulk inserts faster for INSERT ... SELECT, INSERT ... VALUES (...), (...), ..., and LOAD DATA INFILE when adding data to non-empty tables. 31
  175. Per connection variables available for tweeking bulk_insert_buffer_size: Dynamic variable - can be set per session Cache to make bulk inserts faster for INSERT ... SELECT, INSERT ... VALUES (...), (...), ..., and LOAD DATA INFILE when adding data to non-empty tables. Limits the size of the cache tree in bytes per thread. 31
  176. Per connection variables available for tweeking bulk_insert_buffer_size: Dynamic variable - can be set per session Cache to make bulk inserts faster for INSERT ... SELECT, INSERT ... VALUES (...), (...), ..., and LOAD DATA INFILE when adding data to non-empty tables. Limits the size of the cache tree in bytes per thread. Set to 0 disables the optimization used 31
  177. Per connection variables available for tweeking 32
  178. Per connection variables available for tweeking join_buffer_size: 32
  179. Per connection variables available for tweeking join_buffer_size: Dynamic variable - can be set per session 32
  180. Per connection variables available for tweeking join_buffer_size: Dynamic variable - can be set per session Size of the buffer that is used for plain index scans, range index scans, and joins that do not use indexes - full table scans. 32
  181. Per connection variables available for tweeking join_buffer_size: Dynamic variable - can be set per session Size of the buffer that is used for plain index scans, range index scans, and joins that do not use indexes - full table scans. The best way to get fast joins is to add indexes. 32
  182. Per connection variables available for tweeking join_buffer_size: Dynamic variable - can be set per session Size of the buffer that is used for plain index scans, range index scans, and joins that do not use indexes - full table scans. The best way to get fast joins is to add indexes. Band Aid - don’t depend on it. 32
  183. 33
  184. 33
  185. MySQL Performance Tuning 101 Ligaya Turmelle MySQL Support Engineer ligaya@mysql.com 34

×