The document provides an overview of how to summarize and interpret information from MySQL server status and variable outputs to understand server performance and optimize configuration. It explains that status variables show current server activity levels, while global and session variables display configuration settings. Comparing status outputs over time calculates rates like queries/second. Key metrics help identify bottlenecks like a small key buffer size if the key read cache miss rate is high.
Report
Share
Report
Share
1 of 185
More Related Content
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
185. MySQL Performance
Tuning 101
Ligaya Turmelle
MySQL Support Engineer
ligaya@mysql.com
34
Editor's Notes
Queries Systems - soft skill - like design
* Slow query log * OS - is such a thing as over optimizing
- time (long_query_time) * FileSystem
- not use indexes * Network
* EXPLAIN * Storage
* Indexes strategies
* Database design
Queries Systems - soft skill - like design
* Slow query log * OS - is such a thing as over optimizing
- time (long_query_time) * FileSystem
- not use indexes * Network
* EXPLAIN * Storage
* Indexes strategies
* Database design
Queries Systems - soft skill - like design
* Slow query log * OS - is such a thing as over optimizing
- time (long_query_time) * FileSystem
- not use indexes * Network
* EXPLAIN * Storage
* Indexes strategies
* Database design
Queries Systems - soft skill - like design
* Slow query log * OS - is such a thing as over optimizing
- time (long_query_time) * FileSystem
- not use indexes * Network
* EXPLAIN * Storage
* Indexes strategies
* Database design
Queries Systems - soft skill - like design
* Slow query log * OS - is such a thing as over optimizing
- time (long_query_time) * FileSystem
- not use indexes * Network
* EXPLAIN * Storage
* Indexes strategies
* Database design
Global - Once - key buffer, InnoDB buffer pool size
As needed - table and thread cache
Global - Once - key buffer, InnoDB buffer pool size
As needed - table and thread cache
Global - Once - key buffer, InnoDB buffer pool size
As needed - table and thread cache
Global - Once - key buffer, InnoDB buffer pool size
As needed - table and thread cache
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
* Where do I look for information
- Variables - LOTS of information.
example of finding the delta
example of finding the delta
example of finding the delta
example of finding the delta
example of finding the delta
example of finding the delta
Innodb_buffer_pool_wait_free
Normally, writes to the InnoDB buffer pool happen in the background. However, if it is necessary to read or create a page and no clean pages are available, it is also necessary to wait for pages to be flushed first. This counter counts instances of these waits. If the buffer pool size has been set properly, this value should be small. Added in MySQL 5.0.2.
Innodb_buffer_pool_wait_free
Normally, writes to the InnoDB buffer pool happen in the background. However, if it is necessary to read or create a page and no clean pages are available, it is also necessary to wait for pages to be flushed first. This counter counts instances of these waits. If the buffer pool size has been set properly, this value should be small. Added in MySQL 5.0.2.
Innodb_buffer_pool_wait_free
Normally, writes to the InnoDB buffer pool happen in the background. However, if it is necessary to read or create a page and no clean pages are available, it is also necessary to wait for pages to be flushed first. This counter counts instances of these waits. If the buffer pool size has been set properly, this value should be small. Added in MySQL 5.0.2.
Innodb_buffer_pool_wait_free
Normally, writes to the InnoDB buffer pool happen in the background. However, if it is necessary to read or create a page and no clean pages are available, it is also necessary to wait for pages to be flushed first. This counter counts instances of these waits. If the buffer pool size has been set properly, this value should be small. Added in MySQL 5.0.2.
Innodb_buffer_pool_wait_free
Normally, writes to the InnoDB buffer pool happen in the background. However, if it is necessary to read or create a page and no clean pages are available, it is also necessary to wait for pages to be flushed first. This counter counts instances of these waits. If the buffer pool size has been set properly, this value should be small. Added in MySQL 5.0.2.
Innodb_buffer_pool_wait_free
Normally, writes to the InnoDB buffer pool happen in the background. However, if it is necessary to read or create a page and no clean pages are available, it is also necessary to wait for pages to be flushed first. This counter counts instances of these waits. If the buffer pool size has been set properly, this value should be small. Added in MySQL 5.0.2.
* Ask if people understand how the query cache works and if someone is not familiar with it - give a basic explanation.
* Fragmentation - as Qcache_free_blocks approaches Qcache_total_blocks/2 the more severely fragmented the query cache is.
Manual page fragmentation blurb - http://dev.mysql.com/doc/refman/5.0/en/query-cache-configuration.html
&#x201C; When a query is to be cached, its result (the data sent to the client) is stored in the query cache during result retrieval. Therefore the data usually is not handled in one big chunk. The query cache allocates blocks for storing this data on demand, so when one block is filled, a new block is allocated. Because memory allocation operation is costly (timewise), the query cache allocates blocks with a minimum size given by the query_cache_min_res_unit system variable. When a query is executed, the last result block is trimmed to the actual data size so that unused memory is freed. Depending on the types of queries your server executes, you might find it helpful to tune the value of query_cache_min_res_unit:
* The default value of query_cache_min_res_unit is 4KB. This should be adequate for most cases.
* If you have a lot of queries with small results, the default block size may lead to memory fragmentation, as indicated by a large number of free blocks. Fragmentation can force the query cache to prune (delete) queries from the cache due to lack of memory. In this case, you should decrease the value of query_cache_min_res_unit. The number of free blocks and queries removed due to pruning are given by the values of the Qcache_free_blocks and Qcache_lowmem_prunes status variables.
* If most of your queries have large results (check the Qcache_total_blocks and Qcache_queries_in_cache status variables), you can increase performance by increasing query_cache_min_res_unit. However, be careful to not make it too large (see the previous item).&#x201D;
* Ask if people understand how the query cache works and if someone is not familiar with it - give a basic explanation.
* Fragmentation - as Qcache_free_blocks approaches Qcache_total_blocks/2 the more severely fragmented the query cache is.
Manual page fragmentation blurb - http://dev.mysql.com/doc/refman/5.0/en/query-cache-configuration.html
&#x201C; When a query is to be cached, its result (the data sent to the client) is stored in the query cache during result retrieval. Therefore the data usually is not handled in one big chunk. The query cache allocates blocks for storing this data on demand, so when one block is filled, a new block is allocated. Because memory allocation operation is costly (timewise), the query cache allocates blocks with a minimum size given by the query_cache_min_res_unit system variable. When a query is executed, the last result block is trimmed to the actual data size so that unused memory is freed. Depending on the types of queries your server executes, you might find it helpful to tune the value of query_cache_min_res_unit:
* The default value of query_cache_min_res_unit is 4KB. This should be adequate for most cases.
* If you have a lot of queries with small results, the default block size may lead to memory fragmentation, as indicated by a large number of free blocks. Fragmentation can force the query cache to prune (delete) queries from the cache due to lack of memory. In this case, you should decrease the value of query_cache_min_res_unit. The number of free blocks and queries removed due to pruning are given by the values of the Qcache_free_blocks and Qcache_lowmem_prunes status variables.
* If most of your queries have large results (check the Qcache_total_blocks and Qcache_queries_in_cache status variables), you can increase performance by increasing query_cache_min_res_unit. However, be careful to not make it too large (see the previous item).&#x201D;
* Ask if people understand how the query cache works and if someone is not familiar with it - give a basic explanation.
* Fragmentation - as Qcache_free_blocks approaches Qcache_total_blocks/2 the more severely fragmented the query cache is.
Manual page fragmentation blurb - http://dev.mysql.com/doc/refman/5.0/en/query-cache-configuration.html
&#x201C; When a query is to be cached, its result (the data sent to the client) is stored in the query cache during result retrieval. Therefore the data usually is not handled in one big chunk. The query cache allocates blocks for storing this data on demand, so when one block is filled, a new block is allocated. Because memory allocation operation is costly (timewise), the query cache allocates blocks with a minimum size given by the query_cache_min_res_unit system variable. When a query is executed, the last result block is trimmed to the actual data size so that unused memory is freed. Depending on the types of queries your server executes, you might find it helpful to tune the value of query_cache_min_res_unit:
* The default value of query_cache_min_res_unit is 4KB. This should be adequate for most cases.
* If you have a lot of queries with small results, the default block size may lead to memory fragmentation, as indicated by a large number of free blocks. Fragmentation can force the query cache to prune (delete) queries from the cache due to lack of memory. In this case, you should decrease the value of query_cache_min_res_unit. The number of free blocks and queries removed due to pruning are given by the values of the Qcache_free_blocks and Qcache_lowmem_prunes status variables.
* If most of your queries have large results (check the Qcache_total_blocks and Qcache_queries_in_cache status variables), you can increase performance by increasing query_cache_min_res_unit. However, be careful to not make it too large (see the previous item).&#x201D;
* Ask if people understand how the query cache works and if someone is not familiar with it - give a basic explanation.
* Fragmentation - as Qcache_free_blocks approaches Qcache_total_blocks/2 the more severely fragmented the query cache is.
Manual page fragmentation blurb - http://dev.mysql.com/doc/refman/5.0/en/query-cache-configuration.html
&#x201C; When a query is to be cached, its result (the data sent to the client) is stored in the query cache during result retrieval. Therefore the data usually is not handled in one big chunk. The query cache allocates blocks for storing this data on demand, so when one block is filled, a new block is allocated. Because memory allocation operation is costly (timewise), the query cache allocates blocks with a minimum size given by the query_cache_min_res_unit system variable. When a query is executed, the last result block is trimmed to the actual data size so that unused memory is freed. Depending on the types of queries your server executes, you might find it helpful to tune the value of query_cache_min_res_unit:
* The default value of query_cache_min_res_unit is 4KB. This should be adequate for most cases.
* If you have a lot of queries with small results, the default block size may lead to memory fragmentation, as indicated by a large number of free blocks. Fragmentation can force the query cache to prune (delete) queries from the cache due to lack of memory. In this case, you should decrease the value of query_cache_min_res_unit. The number of free blocks and queries removed due to pruning are given by the values of the Qcache_free_blocks and Qcache_lowmem_prunes status variables.
* If most of your queries have large results (check the Qcache_total_blocks and Qcache_queries_in_cache status variables), you can increase performance by increasing query_cache_min_res_unit. However, be careful to not make it too large (see the previous item).&#x201D;
* Ask if people understand how the query cache works and if someone is not familiar with it - give a basic explanation.
* Fragmentation - as Qcache_free_blocks approaches Qcache_total_blocks/2 the more severely fragmented the query cache is.
Manual page fragmentation blurb - http://dev.mysql.com/doc/refman/5.0/en/query-cache-configuration.html
&#x201C; When a query is to be cached, its result (the data sent to the client) is stored in the query cache during result retrieval. Therefore the data usually is not handled in one big chunk. The query cache allocates blocks for storing this data on demand, so when one block is filled, a new block is allocated. Because memory allocation operation is costly (timewise), the query cache allocates blocks with a minimum size given by the query_cache_min_res_unit system variable. When a query is executed, the last result block is trimmed to the actual data size so that unused memory is freed. Depending on the types of queries your server executes, you might find it helpful to tune the value of query_cache_min_res_unit:
* The default value of query_cache_min_res_unit is 4KB. This should be adequate for most cases.
* If you have a lot of queries with small results, the default block size may lead to memory fragmentation, as indicated by a large number of free blocks. Fragmentation can force the query cache to prune (delete) queries from the cache due to lack of memory. In this case, you should decrease the value of query_cache_min_res_unit. The number of free blocks and queries removed due to pruning are given by the values of the Qcache_free_blocks and Qcache_lowmem_prunes status variables.
* If most of your queries have large results (check the Qcache_total_blocks and Qcache_queries_in_cache status variables), you can increase performance by increasing query_cache_min_res_unit. However, be careful to not make it too large (see the previous item).&#x201D;
* If it is set to a value that is not a multiple of 4KB, its value will be rounded down to the nearest multiple of 4KB.
* If it is set to a value that is not a multiple of 4KB, its value will be rounded down to the nearest multiple of 4KB.
* If it is set to a value that is not a multiple of 4KB, its value will be rounded down to the nearest multiple of 4KB.
* If it is set to a value that is not a multiple of 4KB, its value will be rounded down to the nearest multiple of 4KB.
* If it is set to a value that is not a multiple of 4KB, its value will be rounded down to the nearest multiple of 4KB.
* If it is set to a value that is not a multiple of 4KB, its value will be rounded down to the nearest multiple of 4KB.
* If it is set to a value that is not a multiple of 4KB, its value will be rounded down to the nearest multiple of 4KB.