<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-1559905463192401345</atom:id><lastBuildDate>Wed, 22 May 2013 02:50:13 +0000</lastBuildDate><category>GET DIAGNOSTICS</category><category>5.6</category><category>SQLFiddle</category><category>TUNING</category><category>SIGNAL</category><category>SIZING</category><category>MySQL</category><category>PERFORMANCE_SCHEMA</category><category>OVERHEAD</category><category>5.6.10</category><category>USER_GUIDE</category><category>CONFIGURATION</category><category>RESIGNAL</category><title>Marc Alff's blog</title><description></description><link>http://marcalff.blogspot.com/</link><managingEditor>noreply@blogger.com (Marc Alff)</managingEditor><generator>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-2083590236540065886</guid><pubDate>Thu, 16 May 2013 10:02:00 +0000</pubDate><atom:updated>2013-05-16T12:02:27.240+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>Spreading the word about the Performance Schema</title><description>In case you missed it, more and more people are now spreading the word about the Performance Schema, which is a very good thing.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;#DBHangOps 4/10/13 &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Mark Leith &lt;a href="http://www.geoffreyanderson.net/blog/2013/04/08/dbhangops-41013-pre-percona-conference/"&gt;presents&lt;/a&gt; the Performance Schema and ps_helpers.&lt;br /&gt;
&lt;br /&gt;
Random quotes from the recording:&lt;br /&gt;
"I am already seeing so many benefits out of this, ..."&lt;br /&gt;
"This looks fantastic"&lt;br /&gt;
"Very cool"&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;OurSQL Episode 139: Starting to Perform&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Sheeri and Gerry &lt;a href="http://technocation.org/content/oursql-episode-139%3A-starting-perform"&gt;present&lt;/a&gt; the Performance Schema.&lt;br /&gt;
&lt;br /&gt;
Ramdom quote from the recording:&lt;br /&gt;
"I am looking at this feature [digests], and I think it's amazing"&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Webinar: MySQL 5.6 Performance Schema&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
PeterZ &lt;a href="http://www.mysqlperformanceblog.com/2013/05/13/webinar-mysql-5-6-performance-schema/"&gt;presents&lt;/a&gt; the Performance Schema, and ps_helpers, followed by a Q &amp;amp; A session with myself as a special quest.&lt;br /&gt;
&lt;br /&gt;
Watch for updates with the recording, I don't want to add quotes just from memory (there are good ones too).&lt;br /&gt;
&lt;br /&gt;
Marc Alff,&lt;br /&gt;
Performance Schema Architect, &lt;br /&gt;
Oracle.&lt;br /&gt;
&lt;br /&gt;</description><link>http://marcalff.blogspot.com/2013/05/spreading-word-about-performance-schema.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-1370983425678224881</guid><pubDate>Tue, 16 Apr 2013 09:29:00 +0000</pubDate><atom:updated>2013-04-16T11:32:00.504+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>SIZING</category><category domain='http://www.blogger.com/atom/ns#'>CONFIGURATION</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><category domain='http://www.blogger.com/atom/ns#'>USER_GUIDE</category><title>On configuring the Performance Schema</title><description>On configuring the Performance Schema&lt;br /&gt;
&lt;br /&gt;
This article is a user guide about MySQL 5.6 Performance Schema configuration.  As with many things, the way to approach problems may vary a lot based on systems, user experiences, or just plain opinions, so the "Your Mileage May Vary" caution applies here.&lt;br /&gt;
&lt;br /&gt;
It is easy to get lost in details, and yet starting with the big picture in mind helps to understand not only how, but also more importantly why, to do things ...&lt;br /&gt;
&lt;br /&gt;
The magic recipe is as follows&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Define your goals&lt;/li&gt;
&lt;li&gt;Define what to instrument&lt;/li&gt;
&lt;li&gt;Define how much detail to collect&lt;/li&gt;
&lt;li&gt;Provide sizing data&lt;/li&gt;
&lt;li&gt;Monitor sizing problems&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;h1&gt;Define your goals&lt;/h1&gt;&lt;br /&gt;
Performance instrumentation in general can be used for many different things, ranging from casual monitoring in production to debugging in development, with every flavor in between.&lt;br /&gt;
&lt;br /&gt;
Deciding what to instrument is a balancing act.  Too little instrumented means too little functionality provided.  Too much instrumented means too many details, making the result itself hard to interpret.  Depending on the workload, it may be just fine or it could be too much overhead.&lt;br /&gt;
&lt;br /&gt;
In general, instrumentation should typically be on items you have direct control on, and not on just everything available just because it is there.&lt;br /&gt;
&lt;br /&gt;
Some examples to illustrate:&lt;br /&gt;
&lt;br /&gt;
A developer maintaining a SQL application will want to know about SQL statements, because these are the items that can be changed, improved, optimized, etc.&lt;br /&gt;
&lt;br /&gt;
Likewise, someone nurturing the database schema will want to know about load by table, to understand which part of the schema might need improvement, where to change indexes, or which tables to change, normalize, denormalize, etc.&lt;br /&gt;
&lt;br /&gt;
A developer writing code in the server itself, or in a storage engine, will want to know about internal server bottlenecks, and will need the mutex and related instrumentation.&lt;br /&gt;
&lt;br /&gt;
While every goal is valid by itself, chances are that every task is not performed in the same MySQL instance (you do not debug your custom C plugin code directly in the business critical database used in production, do you ?).&lt;br /&gt;
&lt;br /&gt;
Performance instrumentation can be, and most likely is, different per server deployment.&lt;br /&gt;
&lt;br /&gt;
Instrumentation goals should reflect that.&lt;br /&gt;
&lt;br /&gt;
Note that extreme clarity in goal definition here helps a lot too.&lt;br /&gt;
&lt;br /&gt;
Monitoring how much file io is performed globally (say, for capacity planning) is one goal.&lt;br /&gt;
&lt;br /&gt;
Profiling the server to find which application is causing file io (say, to know which team to send a complaint to) is another goal.&lt;br /&gt;
&lt;br /&gt;
Profiling every statement of an application to find which ones are causing file io (say, to resolve the previous complaint) is yet another goal.&lt;br /&gt;
&lt;br /&gt;
These examples illustrates that even when the general area is the same (file io), the level of instrumentation needed for each task may not be the same.&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;Define what to instrument&lt;/h1&gt;&lt;br /&gt;
The performance schema is in fact a collection of different instrumentations added to the server code.&lt;br /&gt;
&lt;br /&gt;
Broad statements like "With the Performance Schema" are meaningless, since this does not accurately describe what is or is not used, which is ultimately configuration dependent.&lt;br /&gt;
&lt;br /&gt;
Even more confusing, given that new features are available as new releases are published, the definition of "With the Performance Schema" changes with time.&lt;br /&gt;
&lt;br /&gt;
The proper way to reason is to look at each kind of instrumentation individually:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;"wait/io/file/%", for file io&lt;/li&gt;
&lt;li&gt;"wait/io/socket/%", for network io&lt;/li&gt;
&lt;li&gt;"wait/io/table/%", for table io&lt;/li&gt;
&lt;li&gt;"wait/lock/table/%", for table locks&lt;/li&gt;
&lt;li&gt;"wait/synch/cond/%", for conditions&lt;/li&gt;
&lt;li&gt;"wait/synch/mutex/%", for mutexes&lt;/li&gt;
&lt;li&gt;"wait/synch/rwlock/%", for read write locks&lt;/li&gt;
&lt;li&gt;"stage/%", for stages&lt;/li&gt;
&lt;li&gt;"idle", for clients idle time.&lt;/li&gt;
&lt;li&gt;"statement/com/%", for raw commands in the client/server protocol&lt;/li&gt;
&lt;li&gt;"statement/sql/%", for SQL queries.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
And then, for each instrumentation, decide if the instrumentation is either needed as a whole or not, to support your goals.&lt;br /&gt;
&lt;br /&gt;
By default, the server ships with the following enabled only:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;File io,&lt;/li&gt;
&lt;li&gt;Table io,&lt;/li&gt;
&lt;li&gt;Table lock,&lt;/li&gt;
&lt;li&gt;Statements,&lt;/li&gt;
&lt;li&gt;Idle instrumentation.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
These defaults are meant to fit what we expect most deployments will need, so it should be a good starting point.&lt;br /&gt;
&lt;br /&gt;
If you have specific requirements, reviewing that list to:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;add the instrumentation you need&lt;/li&gt;
&lt;li&gt;remove the instrumentation you do not need&lt;/li&gt;
&lt;/ul&gt;will be a huge step towards making the Performance Schema:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;actually give results where you expect them,&lt;/li&gt;
&lt;li&gt;reduce overhead by not computing statistics which are not even looked at.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
In configuration terms, "what to instrument" is controlled by the content of table setup_instruments.&lt;br /&gt;
&lt;br /&gt;
If any changes beside out of the box values are needed, the my.cnf option to use is performance-schema-instrument.&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;Define how much detail to collect&lt;/h1&gt;&lt;br /&gt;
One aspect which seems less known is that, when talking about a given instrumentation, the Performance Schema can give more or less details about events recorded.&lt;br /&gt;
&lt;br /&gt;
More details means a better functionality, but also needs more computation and can imply a greater overhead.&lt;br /&gt;
&lt;br /&gt;
In configuration terms, "how much detail to collect" is controlled by the content of table setup_consumers.&lt;br /&gt;
&lt;br /&gt;
The pattern is the same for all instrumentation.&lt;br /&gt;
&lt;br /&gt;
For statements for example, all the following consumers:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;global_instrumentation&lt;/li&gt;
&lt;li&gt;thread_instrumentation&lt;/li&gt;
&lt;li&gt;statements_digest&lt;/li&gt;
&lt;li&gt;events_statements_current&lt;/li&gt;
&lt;li&gt;events_statements_history&lt;/li&gt;
&lt;li&gt;events_statements_history_long&lt;/li&gt;
&lt;/ul&gt;affect one way or another how the statement instrumentation collects data.&lt;br /&gt;
&lt;br /&gt;
The "global_instrumentation" is the master runtime switch which controls whether the Performance Schema is enabled or not, so obviously this consumer should be enabled.&lt;br /&gt;
&lt;br /&gt;
The "thread_instrumentation" controls whether statistics are collected by thread, or just globally. If you need statistics aggregated by account or user or host, these rely on the per thread instrumentation.&lt;br /&gt;
&lt;br /&gt;
The "statement_digests" consumer controls whether query digests are computed and aggregated to produce statistics grouped by queries signatures in table performance_schema.events_statements_summary_by_digest.&lt;br /&gt;
&lt;br /&gt;
The consumer "events_statement_current" controls if the table performance_schema.events_statements_current is populated or not.  This table contains much more details about each statements beside global or per thread metrics, with many attributes not found elsewhere.&lt;br /&gt;
&lt;br /&gt;
Consumers "events_statements_history" and "events_statements_history_long" further control if historical data is preserved or not, with two different retention policies.&lt;br /&gt;
&lt;br /&gt;
In terms of performance impact, instrumenting statements can mean anything&lt;br /&gt;
from:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;do nothing (global_instrumentation is disabled)&lt;/li&gt;
&lt;li&gt;collect a few columns in 1 table (global_instrumentation alone is enabled)&lt;/li&gt;
&lt;/ul&gt;to collecting data for all columns in all 9 events_statements_* tables, possibly with fancy features like query digests.&lt;br /&gt;
&lt;br /&gt;
Picking the right level of details needed to support the instrumentation goals is critical.&lt;br /&gt;
&lt;br /&gt;
By default, the following consumers are enabled:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;global_instrumentation&lt;/li&gt;
&lt;li&gt;thread_instrumentation&lt;/li&gt;
&lt;li&gt;statements_digest&lt;/li&gt;
&lt;li&gt;events_statements_current&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
This list is again meant to be a reasonable starting point when not knowing where to start, but it by no means is what you have to use.&lt;br /&gt;
&lt;br /&gt;
Some points to consider when deciding which consumer to add or remove from this list.&lt;br /&gt;
&lt;br /&gt;
For digests, the computation will take some CPU, so if nobody (be a script, a human, a monitoring application) is even looking at table events_statements_summary_by_digest, there is no point in keeping the consumer "statements_digest" enabled.&lt;br /&gt;
&lt;br /&gt;
For current statements, if there is a need to monitor progress of a live query (which table events_statements_current allows), or to see individual queries with greater details, the consumer "events_statement_current" should be enabled.  Otherwise, this is a good candidate to disable.&lt;br /&gt;
&lt;br /&gt;
A special note about the thread instrumentation: even if there is no functional reason to enable it (i.e., there is no need to get per user statistics), there could be a technical reason to use it.  The technical background is complex, but this is worth mentioning.  By forcing the code to keep per thread statistics buffer, locality of memory access is actually improved, and concurrent access to the same memory locations is reduced, which seem to benefit a lot machines with many cores.&lt;br /&gt;
&lt;br /&gt;
Long story short, do not disable the thread instrumentation and automatically assumes it must cause overhead, benchmark first.&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;Provide sizing data&lt;/h1&gt;&lt;br /&gt;
Defining the content of tables setup_instruments and setup_consumers is one major part that tells the performance schema what to instrument.&lt;br /&gt;
&lt;br /&gt;
Now, the second major part is to find room to store the collected data somewhere ... this is where sizing comes into play.&lt;br /&gt;
&lt;br /&gt;
The Performance Schema sizing parameters are the following (do not look at the values, this is just a test instance).&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; show global variables like "performance_schema%";
+--------------------------------------------------------+-------+
| Variable_name                                          | Value |
+--------------------------------------------------------+-------+
| performance_schema                                     | ON    |
| performance_schema_accounts_size                       | 100   |
| performance_schema_digests_size                        | 200   |
| performance_schema_events_stages_history_long_size     | 1000  |
| performance_schema_events_stages_history_size          | 10    |
| performance_schema_events_statements_history_long_size | 1000  |
| performance_schema_events_statements_history_size      | 10    |
| performance_schema_events_waits_history_long_size      | 10000 |
| performance_schema_events_waits_history_size           | 10    |
| performance_schema_hosts_size                          | 100   |
| performance_schema_max_cond_classes                    | 80    |
| performance_schema_max_cond_instances                  | 1000  |
| performance_schema_max_file_classes                    | 50    |
| performance_schema_max_file_handles                    | 32768 |
| performance_schema_max_file_instances                  | 10000 |
| performance_schema_max_mutex_classes                   | 200   |
| performance_schema_max_mutex_instances                 | 5000  |
| performance_schema_max_rwlock_classes                  | 30    |
| performance_schema_max_rwlock_instances                | 5000  |
| performance_schema_max_socket_classes                  | 10    |
| performance_schema_max_socket_instances                | 1000  |
| performance_schema_max_stage_classes                   | 150   |
| performance_schema_max_statement_classes               | 168   |
| performance_schema_max_table_handles                   | 1000  |
| performance_schema_max_table_instances                 | 500   |
| performance_schema_max_thread_classes                  | 50    |
| performance_schema_max_thread_instances                | 200   |
| performance_schema_session_connect_attrs_size          | 2048  |
| performance_schema_setup_actors_size                   | 100   |
| performance_schema_setup_objects_size                  | 100   |
| performance_schema_users_size                          | 100   |
+--------------------------------------------------------+-------+
31 rows in set (0.00 sec)
&lt;/pre&gt;&lt;br /&gt;
The variable named "performance_schema" is just a ON/OFF flag and not an integer, so there are really 30 parameters in total.&lt;br /&gt;
&lt;br /&gt;
While it may seem overwhelming, keep reading.&lt;br /&gt;
&lt;br /&gt;
The following 8 parameters:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;performance_schema_max_cond_classes&lt;/li&gt;
&lt;li&gt;performance_schema_max_file_classes&lt;/li&gt;
&lt;li&gt;performance_schema_max_mutex_classes&lt;/li&gt;
&lt;li&gt;performance_schema_max_rwlock_classes&lt;/li&gt;
&lt;li&gt;performance_schema_max_socket_classes&lt;/li&gt;
&lt;li&gt;performance_schema_max_stage_classes&lt;/li&gt;
&lt;li&gt;performance_schema_max_statement_classes&lt;/li&gt;
&lt;li&gt;performance_schema_max_thread_classes&lt;/li&gt;
&lt;/ul&gt;are guaranteed to be correct just out of the box.&lt;br /&gt;
&lt;br /&gt;
So, why exposing a configuration parameter then ? Because there are remote use cases, for example when a third party storage engine is instrumented with the Performance Schema (and yes, there are some), these parameters needs to be adjusted to account for the instrumentation contributed by the storage engine. Even if these parameters are expected to change very rarely in practice, hard coding is still something to avoid.&lt;br /&gt;
&lt;br /&gt;
The following 6 parameters:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;performance_schema_events_stages_history_long_size&lt;/li&gt;
&lt;li&gt;performance_schema_events_stages_history_size&lt;/li&gt;
&lt;li&gt;performance_schema_events_statements_history_long_size&lt;/li&gt;
&lt;li&gt;performance_schema_events_statements_history_size&lt;/li&gt;
&lt;li&gt;performance_schema_events_waits_history_long_size&lt;/li&gt;
&lt;li&gt;performance_schema_events_waits_history_size&lt;/li&gt;
&lt;/ul&gt;affect directly how much memory is used to keep historical data, but have no impact on CPU. Keeping the default value is perfectly valid and will not have negative effects. Setting a size to 0 to not spend the memory is also perfectly fine, at the cost of some flexibility (no history without a server restart then).&lt;br /&gt;
&lt;br /&gt;
14 down, 16 to go ...&lt;br /&gt;
&lt;br /&gt;
The following 3 parameters:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;performance_schema_accounts_size&lt;/li&gt;
&lt;li&gt;performance_schema_hosts_size&lt;/li&gt;
&lt;li&gt;performance_schema_users_size&lt;/li&gt;
&lt;/ul&gt;indicates how many different users, hosts, or accounts (combinations of 'user_name'@'host_name') are expected to connect to the server.&lt;br /&gt;
&lt;br /&gt;
For one thing, defining these values should be fairly easy (you do define different security users for different applications instead of running everything as root with SUPER privileges, right ? Count them, you have performance_schema_users_size).&lt;br /&gt;
&lt;br /&gt;
For another, the Performance Schema is actually very forgiving if any of these sizing is too low. Statistics may not be collected for each user/host/account there is, but performance will not degrade either.&lt;br /&gt;
&lt;br /&gt;
The parameter performance_schema_session_connect_attrs_size is important to adjust only if there are applications that actually provide extra attributes per connection. This is a brand new feature, and to take advantage of it, the application needs to change the connect code (or at the very minimum the connect string), and use a connector that supports this new feature. In all likelihood, this parameter needs no change for now.&lt;br /&gt;
&lt;br /&gt;
The parameter performance_schema_digests_size indicates how many different query digests can be tracked simultaneously.  If statements digests are not used, this parameter can be ignored.  When used, how many different digests are needed is very workload dependent, and can be hard to estimate.  A value too high will mean unused memory, while a value too low will cause too many digests statistics to be collapsed into the NULL sinkhole, making the digest summary less meaningful, but not slower.&lt;br /&gt;
&lt;br /&gt;
The parameters performance_schema_setup_actors_size and performance_schema_setup_objects_size do need to change only if a lot of singularities (turn instrumentation on for this user, turn it off for this table) are defined with explicit INSERT in tables setup_actors or setup_objects. Unless you use these tables, in which case you know how many rows are inserted there, these parameters need no change.&lt;br /&gt;
&lt;br /&gt;
7 more down, only 9 to go ...&lt;br /&gt;
&lt;br /&gt;
The remaining 9 configuration parameters are:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;performance_schema_max_cond_instances&lt;/li&gt;
&lt;li&gt;performance_schema_max_file_handles&lt;/li&gt;
&lt;li&gt;performance_schema_max_file_instances&lt;/li&gt;
&lt;li&gt;performance_schema_max_mutex_instances&lt;/li&gt;
&lt;li&gt;performance_schema_max_rwlock_instances&lt;/li&gt;
&lt;li&gt;performance_schema_max_socket_instances&lt;/li&gt;
&lt;li&gt;performance_schema_max_table_handles&lt;/li&gt;
&lt;li&gt;performance_schema_max_table_instances&lt;/li&gt;
&lt;li&gt;performance_schema_max_thread_instances&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
The bad news is that tuning these 9 parameters is critical, as this directly impacts how the Performance Schema functions internally.  Parameters that are severely undersized will cause internal contentions in the Performance Schema implementation, which in turns is a known cause of overhead.&lt;br /&gt;
&lt;br /&gt;
The good news is that the server can also "auto tune" itself, by computing a value for each internal instrumentation buffer (this is what these parameters are for), based on yet other configuration items.&lt;br /&gt;
&lt;br /&gt;
Namely, the Performance Schema code looks at these "fundamental four":&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;max_connections&lt;/li&gt;
&lt;li&gt;table_definition_cache&lt;/li&gt;
&lt;li&gt;table_open_cache&lt;/li&gt;
&lt;li&gt;open_files_limit&lt;/li&gt;
&lt;/ul&gt;from the server my.cnf file, and use an heuristic to estimate how many instruments of each kind are needed.&lt;br /&gt;
&lt;br /&gt;
Some estimates are trivial: to simplify, 1 connection means 1 thread and 1 socket, so knowing max_connections really helps to size performance_schema_max_thread_instances and performance_schema_max_socket_instances ...&lt;br /&gt;
&lt;br /&gt;
The key takeaway here is that the better a server is tuned for the workload expected, the better the Performance Schema will perform, with a sizing aligned on the expected workload.&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;Monitor sizing problems&lt;/h1&gt;&lt;br /&gt;
With proper sizing, the Performance Schema will use the internal buffers to keep track of instrumented objects in general, and produce statistics as expected.&lt;br /&gt;
&lt;br /&gt;
What happens with "improper" sizing then ?&lt;br /&gt;
&lt;br /&gt;
A sizing parameter set to a high value means a lot of memory used. The memory consumed is fixed and never changes, so nothing will degrade other time.&lt;br /&gt;
&lt;br /&gt;
To help understanding which sizing causes which memory consumption, the Performance Schema expose details with SHOW ENGINE PERFORMANCE_SCHEMA STATUS.&lt;br /&gt;
&lt;br /&gt;
A sizing parameter set to a low value can cause two major effects.&lt;br /&gt;
&lt;br /&gt;
First, this will cause at some points the code to drop statistics / events / instrumented objects on the floor, purely and simply. This is a functional problem, since now statistics collected are only partial, and therefore not trustworthy.&lt;br /&gt;
&lt;br /&gt;
Second, if the workload forces the code to allocate very often instrumentation for new objects (when opening a table, a file, a new session), and if the code spends a lot of time to try (and fail) to find memory for the object to instrument, this is also a technical problem, with code that suddenly causes a bottleneck, degrading performances.&lt;br /&gt;
&lt;br /&gt;
When this happens, a status counter for "lost" data is incremented.&lt;br /&gt;
&lt;br /&gt;
Under normal operations, the Performance Schema should always report zero in all the following indicators.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; show global status like "performance_schema%";
+-----------------------------------------------+-------+
| Variable_name                                 | Value |
+-----------------------------------------------+-------+
| Performance_schema_accounts_lost              | 0     |
| Performance_schema_cond_classes_lost          | 0     |
| Performance_schema_cond_instances_lost        | 0     |
| Performance_schema_digest_lost                | 0     |
| Performance_schema_file_classes_lost          | 0     |
| Performance_schema_file_handles_lost          | 0     |
| Performance_schema_file_instances_lost        | 0     |
| Performance_schema_hosts_lost                 | 0     |
| Performance_schema_locker_lost                | 0     |
| Performance_schema_mutex_classes_lost         | 0     |
| Performance_schema_mutex_instances_lost       | 0     |
| Performance_schema_rwlock_classes_lost        | 0     |
| Performance_schema_rwlock_instances_lost      | 0     |
| Performance_schema_session_connect_attrs_lost | 0     |
| Performance_schema_socket_classes_lost        | 0     |
| Performance_schema_socket_instances_lost      | 0     |
| Performance_schema_stage_classes_lost         | 0     |
| Performance_schema_statement_classes_lost     | 0     |
| Performance_schema_table_handles_lost         | 0     |
| Performance_schema_table_instances_lost       | 0     |
| Performance_schema_thread_classes_lost        | 0     |
| Performance_schema_thread_instances_lost      | 0     |
| Performance_schema_users_lost                 | 0     |
+-----------------------------------------------+-------+
23 rows in set (0.00 sec)
&lt;/pre&gt;&lt;br /&gt;
Any non zero value is a sign that the corresponding sizing parameter is too low and needs to be increased.&lt;br /&gt;
&lt;br /&gt;
Defining the proper sizing might take a few attempts and is a necessary limitation of the Performance Schema "static buffer allocation" design.&lt;br /&gt;
&lt;br /&gt;
This design is a deliberate choice, which avoids completely a different instrumentation pitfall. Assume a different implementation that allocates and frees memory as needed to keep statistics, instead of using a fixed amount of memory. This instrumentation can be very user friendly, for a while.  Then the day comes when the workload measured climbs into uncharted territory, with unanticipated spikes (if you can anticipate, you can provide the sizing data, right ?).&lt;br /&gt;
&lt;br /&gt;
When that day comes, which one is better:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;taking the server down, due to out of memory conditions or swapping, caused by an uncontrollable memory consumption ?&lt;/li&gt;
&lt;li&gt;or cutting the instrumentation off ("lost" counters), and let the server proceed with the workload spike ?&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Ease of use and robustness can sometime be conflicting requirements, the Performance Schema design strongly favors robustness, while providing tuning heuristics to alleviate ease of use annoyances.&lt;br /&gt;
&lt;br /&gt;
Marc Alff,&lt;br /&gt;
Oracle.&lt;br /&gt;
</description><link>http://marcalff.blogspot.com/2013/04/on-configuring-performance-schema.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-6354587321463697675</guid><pubDate>Tue, 05 Feb 2013 13:17:00 +0000</pubDate><atom:updated>2013-02-05T14:17:49.565+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>5.6</category><category domain='http://www.blogger.com/atom/ns#'>5.6.10</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>MySQL 5.6 Performance Schema is GA</title><description>The PERFORMANCE SCHEMA was first introduced in MySQL 5.5, and provided some instrumentation.&lt;br /&gt;
&lt;br /&gt;
With MySQL 5.6, the existing instrumentation has been improved a lot, and a lot of new instrumentation was added also.&lt;br /&gt;
&lt;br /&gt;
Now is a good time to review the overall picture ...&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
The performance schema tables&lt;/h2&gt;
&lt;br /&gt;
In 5.5, the tables available are:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; show tables;
+----------------------------------------------+
| Tables_in_performance_schema&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+----------------------------------------------+
| cond_instances&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_current&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_history&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_history_long&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_summary_by_instance&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_summary_by_thread_by_event_name |
| events_waits_summary_global_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| file_instances&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| file_summary_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| file_summary_by_instance&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| mutex_instances&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| performance_timers&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| rwlock_instances&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| setup_consumers&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| setup_instruments&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| setup_timers&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| threads&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+----------------------------------------------+
17 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;br /&gt;
In 5.6, we have:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; show tables;
+----------------------------------------------------+
| Tables_in_performance_schema&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+----------------------------------------------------+
| accounts&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| cond_instances&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_stages_current&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_stages_history&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_stages_history_long&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_stages_summary_by_account_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_stages_summary_by_host_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_stages_summary_by_thread_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_stages_summary_by_user_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_stages_summary_global_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_statements_current&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_statements_history&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_statements_history_long&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_statements_summary_by_account_by_event_name |
| events_statements_summary_by_digest&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_statements_summary_by_host_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_statements_summary_by_thread_by_event_name&amp;nbsp; |
| events_statements_summary_by_user_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_statements_summary_global_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_current&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_history&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_history_long&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_summary_by_account_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_summary_by_host_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_summary_by_instance&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_summary_by_thread_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_summary_by_user_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| events_waits_summary_global_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| file_instances&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| file_summary_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| file_summary_by_instance&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| host_cache&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| hosts&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| mutex_instances&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| objects_summary_global_by_type&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| performance_timers&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| rwlock_instances&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| session_account_connect_attrs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| session_connect_attrs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| setup_actors&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| setup_consumers&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| setup_instruments&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| setup_objects&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| setup_timers&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| socket_instances&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| socket_summary_by_event_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| socket_summary_by_instance&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| table_io_waits_summary_by_index_usage&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| table_io_waits_summary_by_table&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| table_lock_waits_summary_by_table&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| threads&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| users&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+----------------------------------------------------+
52 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;br /&gt;
The difference itself is, to say the least, significant.&lt;br /&gt;
&lt;br /&gt;
A total of 35 tables have been added. That's right, the number of tables&lt;i&gt; tripled&lt;/i&gt;, going from 17 to 52.&lt;br /&gt;
&lt;br /&gt;
Also, some existing tables have been improved, to provide more functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Focus of 5.5&lt;/h2&gt;
&lt;br /&gt;
The instrumentation provided in 5.5 focuses exclusively on low level waits closely related to the server code itself. Namely, we have pthread mutexes, read write locks, and conditions, all together abbreviated as "mutexes and friends", plus file I/O.&lt;br /&gt;
&lt;br /&gt;
This instrumentation covers (almost, see 5.6) all possible causes for a thread execution to stall and "wait" for something. Having this instrumentation in place is the foundation needed to perform any latency analysis.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Focus of 5.6&lt;/h2&gt;
&lt;br /&gt;
&lt;h3&gt;
More waits&lt;/h3&gt;
&lt;br /&gt;
With 5.6, remaining reasons for a thread to stall have been instrumented as well, with the addition of the network I/O instrumentation, and the "idle" instrumentation. Now that every possible root cause that can cause latency is covered, the "wait" area is functionally complete.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Going SQL level&lt;/h3&gt;
&lt;br /&gt;
With this major part done, 5.6 also instrument things at a higher level, closer to end users. For example, when a database user performs an INSERT into a TABLE, sure, the server and the storage engine at the very end of the code stack might be waiting on a mutex ... but a mutex is just &lt;i&gt;how an operation is implemented&lt;/i&gt;, which is a different point of view from &lt;i&gt;what operation is executed&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
With 5.6, the performance schema expands instrumentation from C level to SQL level, which significantly expands the target audience from server developers or power users to include general database users as well.&lt;br /&gt;
&lt;br /&gt;
The most important SQL object manipulated by SQL applications being a TABLE (doh), 5.6 adds instrumentation for tables, covering table I/O, index I/O and table locks.&lt;br /&gt;
&lt;br /&gt;
What a SQL application uses to manipulate these objects is a query (or statement), and therefore, 5.6 has instrumentation for every SQL statement.&lt;br /&gt;
&lt;br /&gt;
Statement digests are computed on the fly, and aggregated on the fly, in memory.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Stages&lt;/h3&gt;
&lt;br /&gt;
An intermediate level between statements and waits is also covered by the stages instrumentation. It captures the very same data that the SHOW PROFILE feature collects, but presents results in a different way. Note that the performance schema stage instrumentation provides functionality that SHOW PROFILE does not support, such as monitoring stages from another session, and a lot of aggregations with summaries tables.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
More flexibility&lt;/h3&gt;
&lt;br /&gt;
The performance schema in 5.5 already introduced the concept on turning on or off each instrument independently, implemented by the table &lt;b&gt;performance_schema.setup_instruments&lt;/b&gt;, with the enabled column.&lt;br /&gt;
&lt;br /&gt;
Filtering by "instrument", or probe in the server code, is one dimension to the problem, but there are other dimensions as well.&lt;br /&gt;
&lt;br /&gt;
With 5.6, the performance schema can also filter the traffic recorded by users. Assuming different applications are deployed using different user accounts, which happen to be a best practice for security reasons anyway, this means that the performance schema can filter the workload by applications, with the new table &lt;b&gt;performance_schema.setup_actors&lt;/b&gt;. This is a second dimension.&lt;br /&gt;
&lt;br /&gt;
With 5.6 still, the performance schema can also filter the application workload by SQL object, with table &lt;b&gt;performance_schema.setup_objects&lt;/b&gt;. This is the third dimension.&lt;br /&gt;
&lt;br /&gt;
For each new dimension, summary tables are provided as well.&lt;br /&gt;
&lt;br /&gt;
Analysing a workload is a complex problem. This problem can now be "seen in 3D", with filters:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;- enable / disable by instrument with setup_instruments (same as 5.5)&lt;/li&gt;
&lt;li&gt;- enable / disable by user/host/account with setup_actors (new in 5.6)&lt;/li&gt;
&lt;li&gt;- enable / disable by object with setup_objects (new in 5.6)&lt;/li&gt;
&lt;/ul&gt;
or with aggregated summaries:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;- summaries by event_name (same as 5.5)&lt;/li&gt;
&lt;li&gt;- summaries by user/host/account (new in 5.6)&lt;/li&gt;
&lt;li&gt;- summaries by objects (new in 5.6)&lt;/li&gt;
&lt;/ul&gt;
or any combinations, really.&lt;br /&gt;
&lt;br /&gt;
This fundamentally "orthogonal" property of the performance schema instrumentation makes it very powerful tool.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
State information&lt;/h3&gt;
&lt;br /&gt;
While 5.5 only reports "wait" data in the performance schema, 5.6 also contains "state" data.&lt;br /&gt;
&lt;br /&gt;
The &lt;b&gt;performance_schema.host_cache&lt;/b&gt; table fits in this category, as it exposes the internal server host_cache, which for the circumstance has been also greatly enhanced. Using the performance_schema.host_cache, a DBA can see at once not only &lt;i&gt;if&lt;/i&gt; a connection from a client is rejected, but also &lt;i&gt;why&lt;/i&gt;, and for &lt;i&gt;which client&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
While this just sounds obvious functionality that should be there, it has not always been such a given in MySQL history. DBA who administer very large deployments should appreciate this new feature.&lt;br /&gt;
&lt;br /&gt;
Another area where the performance schema exposes state is connection metadata.&lt;br /&gt;
&lt;br /&gt;
The client server protocol in 5.6 was enhanced to allow a connecting application to provide connection attributes. These attributes are exposed in the performance schema in table &lt;b&gt;performance_schema.session_connect_attrs&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
The server implementation itself does nothing with it, and yet this data is priceless: this allows a DBA to correlate a session in the database server with a specific component or object in the client application.&lt;br /&gt;
&lt;br /&gt;
For example, a connection running queries to render a page in HTML for a web server could be marked with the originating URL. Tracing where exactly queries do come from (say, in case they need to be improved) can be much easier now.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Improved easy of use&lt;/h3&gt;
&lt;br /&gt;
Configuring the performance schema has never been easier.&lt;br /&gt;
&lt;br /&gt;
For once, it is enabled by default out of the box.&lt;br /&gt;
&lt;br /&gt;
The default configuration has been chosen to provide the functionality we expect most DBA will need the most. Of course, nothing is hard coded, and defaults can be changed.&lt;br /&gt;
&lt;br /&gt;
Secondly, the configuration to use can be saved permanently in the server my.cnf file. This is a major improvement over 5.5, which forces the use of DML statements.&lt;br /&gt;
&lt;br /&gt;
A previously big task was to provide a lot of sizing parameters in 5.5. Third improvement with 5.6, the sizing still exists, but there is also a new helper: if the DBA really does not know how to size a parameter, in most cases it can be automatically sized by the server, with embedded heuristics. With the magic "-1" value for a performance schema sizing parameter, the code will do the math based on existing key server parameters. And when auto sizing is available, it is ... the default.&lt;br /&gt;
&lt;br /&gt;
Other ease of use improvements relates to the structure of the performance schema table themselves. As events of different kind are related or nested within each others, detailed individual events recorded in different history tables form together a complex hierarchy.&lt;br /&gt;
&lt;br /&gt;
To help any application to navigate this hierarchy the way it makes the most sense for the application, the performance schema implements, at the same time, both the "nested set" and the "adjacency list" &lt;a href="http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/"&gt;data model&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Reduced runtime overhead&lt;/h3&gt;
&lt;br /&gt;
Last but not least, during the overall development cycle of 5.6, the performance schema implementation has been benchmarked, tuned, optimized, sometime re designed, sometime re factored, and all the above happened several times during several iterations.&lt;br /&gt;
&lt;br /&gt;
The overall result of this work is now available in 5.6, which implements numerous performance improvements.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Get ready, MySQL 5.6.10 is now GA&lt;/h2&gt;
&lt;br /&gt;
Adding the PERFORMANCE SCHEMA in MySQL 5.5 was a major leap forward compared to 5.1.&lt;br /&gt;
&lt;br /&gt;
The PERFORMANCE SCHEMA in MySQL 5.6 also is a leap forward compared to 5.5 ...&lt;br /&gt;
&lt;br /&gt;
A &lt;i&gt;quantum&lt;/i&gt; leap.&lt;br /&gt;
&lt;br /&gt;
Marc Alff,&lt;br /&gt;
MySQL Performance Schema Architect,&lt;br /&gt;
Oracle.&lt;br /&gt;
&lt;br /&gt;</description><link>http://marcalff.blogspot.com/2013/02/mysql-56-performance-schema-is-ga.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-3052995477113686235</guid><pubDate>Wed, 03 Oct 2012 19:33:00 +0000</pubDate><atom:updated>2012-10-03T21:34:02.087+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><category domain='http://www.blogger.com/atom/ns#'>SQLFiddle</category><title>Fiddle with the Performance Schema</title><description>&lt;br /&gt;
I recently found an interesting tool to play with databases, &lt;a href="http://sqlfiddle.com/"&gt;SQLFiddle&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The tool is used to share some fragments of code, running on a live database, to allow users to not only see (read) the code, but also actually execute it, to play with the code.&lt;br /&gt;
&lt;br /&gt;
See &lt;a href="http://sqlfiddle.com/about.html"&gt;this link&lt;/a&gt; for all the details.&lt;br /&gt;
&lt;br /&gt;
The nice part is that MySQL 5.5 is part of the supported databases, &lt;a href="http://sqlfiddle.com/#!2"&gt;try it here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
It gets better: MySQL 5.6 is also there, so you get to &lt;a href="http://sqlfiddle.com/#!9"&gt;try new 5.6 features&lt;/a&gt;, or your favorite query, in a blink, without having to do an installation.&lt;br /&gt;
&lt;br /&gt;
And icing on the 5.6 cake, the PERFORMANCE_SCHEMA is also enabled, with grants given to the user to query performance schema tables.&lt;br /&gt;
&lt;br /&gt;
For example, this is a small "sqlfiddle" that shows &lt;a href="http://sqlfiddle.com/#!9/322fd/7"&gt;how this works&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
As you can see looking at the results after executing this code fragment, the performance schema is there, ready for you to play with it.&lt;br /&gt;
&lt;br /&gt;
Marc Alff,&lt;br /&gt;
Oracle&lt;br /&gt;
&lt;br /&gt;
P.S.&lt;br /&gt;
&lt;br /&gt;
Views expressed here are my own.&lt;br /&gt;
Not a product or service endorsement. &lt;br /&gt;
&lt;br /&gt;</description><link>http://marcalff.blogspot.com/2012/10/fiddle-with-performance-schema.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-5261439933937349617</guid><pubDate>Wed, 11 Apr 2012 18:31:00 +0000</pubDate><atom:updated>2012-04-11T20:32:19.839+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>Performance Schema, nailing the host cache coffin down</title><description>Every old mansion has some old history, and the older it is, the scarier it gets ...&lt;br /&gt;
&lt;br /&gt;
MySQL is no exception: there are some very old ghosts still lurking inside the server.&lt;br /&gt;
&lt;br /&gt;
One of these ghosts is the 'host cache', which haunts the server main entrance halls, just right pass the TCP/IP front door.&lt;br /&gt;
&lt;br /&gt;
How long has this ghost been there ? From the very beginning it seems, as is was first &lt;a href="http://blog.jcole.us/2006/04/26/on-ips-hostnames-and-mysql/"&gt;spotted&lt;/a&gt; on April 26, 2006 ... Yes, that was 6 years ago, back in the 4.1 old times.&lt;br /&gt;
&lt;br /&gt;
This ghost has been haunting DBA's worst nightmares since then.&lt;br /&gt;
&lt;br /&gt;
Public sightings include:&lt;br /&gt;
- &lt;a href="http://bugs.mysql.com/bug.php?id=22821"&gt;Bug#22821&lt;/a&gt; Adding "SHOW HOST_CACHE" patch from Jeremy Cole&lt;br /&gt;
- &lt;a href="http://bugs.mysql.com/bug.php?id=24906"&gt;Bug#24906&lt;/a&gt; No command to monitor blocked hosts&lt;br /&gt;
- &lt;a href="http://bugs.mysql.com/bug.php?id=45817"&gt;Bug#45817&lt;/a&gt; Please add SHOW command for inc_host_errors(max_connect_errors)&lt;br /&gt;
- &lt;a href="http://bugs.mysql.com/bug.php?id=50963"&gt;Bug#50963&lt;/a&gt; add information_schema.error_count&lt;br /&gt;
- &lt;a href="http://bugs.mysql.com/bug.php?id=59404"&gt;Bug#59404&lt;/a&gt; More info from host cache&lt;br /&gt;
- &lt;a href="http://www.facebook.com/notes/mysqlfacebook/monitoring-for-errors/293204560932"&gt;http://www.facebook.com/notes/mysqlfacebook/monitoring-for-errors/293204560932&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Why is the host cache a ghost ?&lt;br /&gt;
&lt;br /&gt;
Because it can not be seen. But make no mistake, it is there, waiting to scare database connections away.&lt;br /&gt;
&lt;br /&gt;
Why is it causing nightmares ?&lt;br /&gt;
&lt;br /&gt;
Because it is speechless (no trace in the log), very stealthy (some people do not know it is there), and yet deadly effective at killing visitors, without telling anyone.&lt;br /&gt;
And definitely without telling any living soul.&lt;br /&gt;
&lt;br /&gt;
If an application ever sees something like &lt;a href="http://dev.mysql.com/doc/refman/5.6/en/blocked-host.html"&gt;this&lt;/a&gt;, then you know this application really did upset the ghost too much, which is now seeing red and killing at first sight.&lt;br /&gt;
&lt;br /&gt;
That last part, the fact that the ghost actually has a spirit of it's own, and will remember an annoying visitor, is what makes it the worst: troubleshooting a system that show some &lt;a href="http://en.wikipedia.org/wiki/Hysteresis"&gt;hysteresis&lt;/a&gt;, while staying completely in the dark, is no fun at all.&lt;br /&gt;
&lt;br /&gt;
The only thing the host cache ghost would tell anyone, just as a final reminder that is is still lurking, is how many visitors got &lt;a href="http://dev.mysql.com/doc/refman/5.6/en/server-status-variables.html#statvar_Aborted_connects"&gt;killed&lt;/a&gt;.&lt;br /&gt;
No when, no why, no who ... just a casualty report.&lt;br /&gt;
&lt;br /&gt;
While keeping unwanted visitors out might be a good thing after all, also preventing wanted but poorly configured visitors to connect to the database is really a bad thing.&lt;br /&gt;
&lt;br /&gt;
This is why this old ghost from the past has now finally been put to rest, thanks to the performance schema in the MySQL 5.6.5-m8 release: see the new table &lt;a href="http://dev.mysql.com/doc/refman/5.6/en/host-cache-table.html"&gt;performance_schema.host_cache&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
With the new performance_schema.host_cache table, not only a DBA can see the host cache content, but the content has been expanded to also see a count for every possible error that can prevent a visitor to get in.&lt;br /&gt;
&lt;br /&gt;
Finally some light in that entrance hall.&lt;br /&gt;
&lt;br /&gt;
Now, we are still in April 2012, and this feature is 6 years overdue, but don't get fooled ... this is not a &lt;a href="http://bazaar.launchpad.net/~mysql/mysql-server/trunk/view/head:/storage/perfschema/table_host_cache.h"&gt;faery tale&lt;/a&gt;.&lt;br /&gt;
The fact that such things can happen might be a reason to believe in &lt;a href="http://bazaar.launchpad.net/~mysql/mysql-server/trunk/view/head:/mysql-test/suite/perfschema/r/hostcache_ipv6_ssl.result#L70"&gt;Santa Claus&lt;/a&gt; again.&lt;br /&gt;
&lt;br /&gt;
Marc Alff, Oracle.&lt;br /&gt;</description><link>http://marcalff.blogspot.com/2012/04/performance-schema-nailing-host-cache.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-4478882680467637077</guid><pubDate>Fri, 02 Dec 2011 10:16:00 +0000</pubDate><atom:updated>2011-12-02T13:14:16.682+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>Performance schema or COM_ status counters ?</title><description>&lt;br /&gt;
In MySQL 5.6.3, that is, a while ago already, the performance schema added instrumentation for statements.&lt;br /&gt;
&lt;br /&gt;
This major enhancement seem to have gone unnoticed, so a quick review of how it works, especially compared to the existing COM_ status counters that everyone is used to, can perhaps put some light here.&lt;br /&gt;
&lt;br /&gt;
The MySQL server maintains 'COM_%' counters for statements executed.&lt;br /&gt;
&lt;br /&gt;
These counters are available in both the session and global status.&lt;br /&gt;
&lt;br /&gt;
Let's look at a few:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; select variable_name from information_schema.global_status
where variable_name like "com\_%" order by variable_name limit 20;
+------------------------+
| variable_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+------------------------+
| COM_ADMIN_COMMANDS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_ALTER_DB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_ALTER_DB_UPGRADE&amp;nbsp;&amp;nbsp; |
| COM_ALTER_EVENT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_ALTER_FUNCTION&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_ALTER_PROCEDURE&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_ALTER_SERVER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_ALTER_TABLE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_ALTER_TABLESPACE&amp;nbsp;&amp;nbsp; |
| COM_ANALYZE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_ASSIGN_TO_KEYCACHE |
| COM_BEGIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_BINLOG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_CALL_PROCEDURE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_CHANGE_DB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_CHANGE_MASTER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_CHECK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_CHECKSUM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_COMMIT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| COM_CREATE_DB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+------------------------+
20 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;br /&gt;
Now, let's take a look at what is instrumented in the performance schema, for statements:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; select name from setup_instruments&lt;/pre&gt;
&lt;pre&gt;where name like "statement/sql/%" order by name limit 20;
+----------------------------------+
| name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+----------------------------------+
| statement/sql/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/alter_db&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/alter_db_upgrade&amp;nbsp;&amp;nbsp; |
| statement/sql/alter_event&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/alter_function&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/alter_procedure&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/alter_server&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/alter_table&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/alter_tablespace&amp;nbsp;&amp;nbsp; |
| statement/sql/analyze&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/assign_to_keycache |
| statement/sql/begin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/binlog&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/call_procedure&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/change_db&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/change_master&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/check&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/checksum&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/commit&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/sql/create_db&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+----------------------------------+
20 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;br /&gt;
The resemblance is striking. In fact, the names present in performance_schema.setup_instruments are derived from the COM_ names, with a few tweaks.&lt;br /&gt;
&lt;br /&gt;
For real SQL statements, such as ALTER TABLE, 'COM_ALTER_TABLE' corresponds to 'statement/sql/alter_table'.&lt;br /&gt;
&lt;br /&gt;
For what show status advertizes as 'admin commands', which is just a common bucket for different things, the performance schema instrumentation actually is more detailed, and gives each command a real name, so that commands from the client/server protocol are visible too:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; select name from setup_instruments&lt;/pre&gt;
&lt;pre&gt;where name like "statement/com/%" order by name;
+------------------------------+
| name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+------------------------------+
| statement/com/Binlog Dump&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Change user&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Close stmt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Connect&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Connect Out&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Create DB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Daemon&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Debug&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Delayed insert |
| statement/com/Drop DB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Error&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Execute&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Fetch&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Field List&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Init DB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Kill&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Long Data&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Ping&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Prepare&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Processlist&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Query&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Quit&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Refresh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Register Slave |
| statement/com/Reset stmt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Set option&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Shutdown&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Sleep&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Statistics&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Table Dump&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
| statement/com/Time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+------------------------------+
31 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;br /&gt;
Overall, there are 140 'COM_%' entries in show status, for 165 'statement/%' entries in the performance schema. The performance schema also count errors with special entries, which is not available in show status. All the details are explained in the &lt;a href="http://dev.mysql.com/doc/refman/5.6/en/performance-schema-statements-tables.html"&gt;documentation&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Now, what about the statistics collected by the statement instrumentation then ?&lt;br /&gt;
&lt;br /&gt;
In SHOW STATUS, each 'COM_%' entry is only a counter. There are counters for the &lt;i&gt;current session&lt;/i&gt; (aka your own connection), and global counters.&lt;br /&gt;
&lt;br /&gt;
In the performance schema, there are more detailed statistics and not just a counter. These statistics are for &lt;i&gt;every session&lt;/i&gt; (table statements_summary_by_thread_by_event_name) or global (table statements_summary_global_by_event_name).&lt;br /&gt;
&lt;br /&gt;
In fact, there are even more levels of aggregation as intermediate steps between SESSION and GLOBAL, with statistics by account, user or host, which the SHOW STATUS command do not provide.&lt;br /&gt;
&lt;br /&gt;
The difference between 'current session' and 'every session' is fundamental ... a monitoring tool needs to see what a monitored application is doing, not itself.&lt;br /&gt;
&lt;br /&gt;
As for details about the data provided, let's take a quick look:&lt;br /&gt;
&lt;br /&gt;
For SHOW STATUS:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; select * from information_schema.global_status&lt;/pre&gt;
&lt;pre&gt;where variable_name like "com_select" \G
*************************** 1. row ***************************
&amp;nbsp;VARIABLE_NAME: COM_SELECT
VARIABLE_VALUE: 34
1 row in set (0.00 sec)
&lt;/pre&gt;
&lt;br /&gt;
For the performance_schema:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; select * from performance_schema.events_statements_summary_global_by_event_name&lt;/pre&gt;
&lt;pre&gt;where event_name like "statement/sql/select" \G
*************************** 1. row ***************************
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EVENT_NAME: statement/sql/select
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COUNT_STAR: 34
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_TIMER_WAIT: 103780188000
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MIN_TIMER_WAIT: 76388000
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AVG_TIMER_WAIT: 3052358000
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAX_TIMER_WAIT: 39010345000
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_LOCK_TIME: 3818000000
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_ERRORS: 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_WARNINGS: 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_ROWS_AFFECTED: 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_ROWS_SENT: 1441
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_ROWS_EXAMINED: 10574
SUM_CREATED_TMP_DISK_TABLES: 2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_CREATED_TMP_TABLES: 14
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_SELECT_FULL_JOIN: 0
&amp;nbsp;SUM_SELECT_FULL_RANGE_JOIN: 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_SELECT_RANGE: 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_SELECT_RANGE_CHECK: 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_SELECT_SCAN: 31
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_SORT_MERGE_PASSES: 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_SORT_RANGE: 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_SORT_ROWS: 1071
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_SORT_SCAN: 24
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_NO_INDEX_USED: 31
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM_NO_GOOD_INDEX_USED: 0
1 row in set (0.00 sec)
&lt;/pre&gt;
&lt;br /&gt;
There are even more differences.&lt;br /&gt;
&lt;br /&gt;
Having statistics is great, but people need to reset them once in a while, still when doing monitoring.&lt;br /&gt;
&lt;br /&gt;
For SHOW STATUS, the command FLUSH STATUS has shortcomings. See feature requests like &lt;a href="http://bugs.mysql.com/bug.php?id=22875"&gt;bug#22875&lt;/a&gt; about it.&lt;br /&gt;
&lt;br /&gt;
The performance schema actually provides the functionality to reset statistics.&lt;br /&gt;
&lt;br /&gt;
The syntax is a bit different: the missing 'FLUSH SESSION STATUS' corresponds to 'TRUNCATE TABLE performance_schema.events_statements_summary_by_thread_by_event_name'.&lt;br /&gt;
&lt;br /&gt;
It is all there in 5.6.3&lt;br /&gt;
&lt;br /&gt;
-- Marc Alff, Oracle.&lt;br /&gt;
&lt;br /&gt;</description><link>http://marcalff.blogspot.com/2011/12/performance-schema-or-com-status.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-4510424502233712638</guid><pubDate>Thu, 01 Dec 2011 21:29:00 +0000</pubDate><atom:updated>2011-12-20T14:31:58.305+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>MySQL 5.6.4 PERFORMANCE SCHEMA</title><description>&lt;h1&gt;

   New performance schema features in 5.6.4&lt;/h1&gt;
&lt;br /&gt;
As development of the 5.6 serie continues, a new milestone (5.6.4) is now available.&lt;br /&gt;
&lt;br /&gt;
The source code for &lt;a href="https://code.launchpad.net/%7Emysql/mysql-server/trunk"&gt;mysql-trunk&lt;/a&gt; is on launchpad, and the &lt;a href="http://dev.mysql.com/doc/refman/5.6/en/performance-schema.html"&gt;MySQL 5.6 documentation&lt;/a&gt; is also public.&lt;br /&gt;
&lt;br /&gt;
In this milestone, a few new performance schema features have been implemented, as can be seen in the &lt;a href="http://dev.mysql.com/doc/refman/5.6/en/news-5-6-4.html"&gt;changelog&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;

  MY.CNF, or easier configuration&lt;/h2&gt;
&lt;br /&gt;
Until now, the performance schema used a very simple, or shall I say, crude, way to decide what needs to be instrumented or not: flip the master switch on (performance_schema), and you get absolutely everything available, with as much details as possible, by default. And then, to change the defaults, the only way was to use DML statements to tell the performance schema to do less.&lt;br /&gt;
&lt;br /&gt;
With the number of instrumented artifacts growing (table setup_instruments went from 212 entries in 5.5 to 503 entries in 5.6.4), and with the number of tables also growing (the performance_schema database went from 17 tables in 5.5 to 48 tables in 5.6.4), there is now the need for a better, easier way to control the instrumented content.&lt;br /&gt;
&lt;br /&gt;
The first major change implemented is that instead of getting all the available instrumentation enabled by default, only a selected few instruments are enabled. For example, not every DBA is interested in knowing the low level implementation details of the server code itself, so things that are only fascinating to server developers like mutexes are disabled. Conversely, DBA are likely to be looking often at statements that applications are executing against the server, so all the statement instrumentation is enabled by default. Nothing is hard coded and everything can be changed. By providing a configuration "out of the box" that is much closer to real production scenarios, the extra work to configure the performance schema exactly how you want it is reduced, a lot. &lt;br /&gt;
&lt;br /&gt;
Similar to limiting which instrument is enabled in the table setup_instruments, the list of consumers enabled by default, which basically controls how much details the instrumentation provides, has been revised. Consumers such as event histories, which contributed a lot to the performance schema overhead only to maintain tables that are after all rarely used, have been turned off by default.&lt;br /&gt;
&lt;br /&gt;
The second major change is that the performance schema does not need to be told again, with DML, what to do after each server startup. The specification about settings in tables setup_instruments and setup_consumers, which again define how many different events are collected and with which level of details, can be written in the server my.cnf file. The syntax in the my.cnf file is simple and powerful enough so that one can tell in one line "disable all the mutexes" or "enable all the file io in this storage engine", without having to even spell out each and every instruments (remember that there are 500+ by now) known to the performance schema.&lt;br /&gt;
&lt;br /&gt;
In short, this new feature should be good news to many people, especially early adopters.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;

  END_EVENT_ID, or easier ways to access hierarchical data&lt;/h2&gt;
&lt;br /&gt;
The performance schema provides data. A lot. With many details.&lt;br /&gt;
&lt;br /&gt;
When looking in particular at individual events, instead of just statistics with aggregations, these events (statements, stages, waits of many different type) all relate to each others and form collectively a big hierarchical data tree.&lt;br /&gt;
&lt;br /&gt;
For a good description of hierarchical data and methods to manipulate it, see this excellent &lt;a href="http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/"&gt;article&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The performance schema tables were already supporting the 'Adjacency List Model', with columns such as NESTING_EVENT_ID in an event pointing to EVENT_ID in a parent event.&lt;br /&gt;
&lt;br /&gt;
With 5.6.4 and the introduction of columns like END_EVENT_ID, the performance schema tables are now &lt;i&gt;also&lt;/i&gt; supporting the 'Nested Set Model'.&lt;br /&gt;
&lt;br /&gt;
That's right, we now support &lt;i&gt;both&lt;/i&gt; models, so an application can use what makes the most sense given the use case.&lt;br /&gt;
&lt;br /&gt;
Why is that important ? Well, people like &lt;a href="http://www.markleith.co.uk/?tag=performance_schema"&gt;Mark Leith&lt;/a&gt; convinced me that it is, in particular because it helps a lot to navigate the data efficiently, for example to produce &lt;a href="http://www.markleith.co.uk/?p=471"&gt;big fancy graphs&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;

  Extended file io statistics&lt;/h2&gt;
&lt;br /&gt;
The file io instrumentation was added in the performance schema in 5.5 already. Unfortunately, the statistics collected by file in 5.5 are not very informative, as only a few columns are provided.&lt;br /&gt;
&lt;br /&gt;
With 5.6.4, the summaries for file io have been revised and improved, to provide more content.&lt;br /&gt;
&lt;br /&gt;
To see the difference, compare side by side the &lt;a href="http://dev.mysql.com/doc/refman/5.5/en/file-summary-tables.html"&gt;5.5 documentation&lt;/a&gt; and the &lt;a href="http://dev.mysql.com/doc/refman/5.6/en/file-summary-tables.html"&gt;5.6 documentation&lt;/a&gt;, and see the new columns.&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;

  Reminder&lt;/h1&gt;
&lt;br /&gt;
MySQL 5.6.4 is not a GA release, and should not be used in production.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Marc Alff, Oracle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://marcalff.blogspot.com/2011/12/mysql-564-performance-schema.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>3</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-8528342417553350794</guid><pubDate>Tue, 18 Oct 2011 08:07:00 +0000</pubDate><atom:updated>2011-10-18T10:36:46.478+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>GET DIAGNOSTICS</category><category domain='http://www.blogger.com/atom/ns#'>RESIGNAL</category><category domain='http://www.blogger.com/atom/ns#'>SIGNAL</category><title>MYSQL GET DIAGNOSTICS</title><description>&lt;br /&gt;
A new feature just got merged into &lt;a href="https://code.launchpad.net/%7Emysql/mysql-server/trunk"&gt;mysql-trunk&lt;/a&gt;, the GET DIAGNOSTICS statement.&lt;br /&gt;
&lt;br /&gt;
Many people have been asking for &lt;a href="http://bugs.mysql.com/bug.php?id=11660"&gt;this&lt;/a&gt; for a very long time, so it is worth mentioning it.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; select version();
+--------------+
| version()&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+--------------+
| 5.6.4-m6-log |
+--------------+
1 row in set (0.00 sec)

mysql&amp;gt; drop table test.no_such_table;
ERROR 1051 (42S02): Unknown table 'test.no_such_table'
&lt;/pre&gt;
&lt;br /&gt;
Why is it important ? In short, it allows to programmatically (i.e., in SQL) inspect what happened in a SQL exception. &lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; get diagnostics condition 1
  @p1 = MESSAGE_TEXT,
  @p2 = RETURNED_SQLSTATE,
  @p3 = MYSQL_ERRNO,
  @p4 = SCHEMA_NAME,
  @p5 = TABLE_NAME;

Query OK, 0 rows affected (0.00 sec)
&lt;/pre&gt;
&lt;br /&gt;
Exception handling code can then inspect attributes of the exception raised, to find out which error in particular occurred. Most critical items are fully implemented.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; select @p1, @p2, @p3;
+------------------------------------+-------+------+
| @p1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | @p2&amp;nbsp;&amp;nbsp; | @p3&amp;nbsp; |
+------------------------------------+-------+------+
| Unknown table 'test.no_such_table' | 42S02 | 1051 |
+------------------------------------+-------+------+
1 row in set (0.00 sec)
&lt;/pre&gt;
&lt;br /&gt;
Unfortunately, others are not fully supported yet.
&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; select @p4, @p5;
+------+------+
| @p4&amp;nbsp; | @p5&amp;nbsp; |
+------+------+
|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |
+------+------+
1 row in set (0.00 sec)
&lt;/pre&gt;
&lt;br /&gt;
The SCHEMA_NAME and TABLE_NAME condition items should be 'test' and 'no_such_table' respectively, indicating which table caused the DROP TABLE statement to fail.&lt;br /&gt;
&lt;br /&gt;
The GET DIAGNOSTICS statement &lt;i&gt;is&lt;/i&gt; implemented, and returns the values found in the server diagnostics area, but what is missing now is to revise the implementation of every statement (such as DROP TABLE) to populate &lt;i&gt;every attribute&lt;/i&gt; of the diagnostics area when raising an error.&lt;br /&gt;
&lt;br /&gt;
While it may not look so impressive at first glance, implementing the GET DIAGNOSTICS statement is actually a huge step forward: now with &lt;a href="http://dev.mysql.com/doc/refman/5.5/en/signal.html"&gt;SIGNAL&lt;/a&gt; and &lt;a href="http://dev.mysql.com/doc/refman/5.5/en/resignal.html"&gt;RESIGNAL&lt;/a&gt;, GET DIAGNOSTICS allows an application to implement proper SQL exception handling.&lt;br /&gt;
&lt;br /&gt;
-- Marc Alff&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;</description><link>http://marcalff.blogspot.com/2011/10/mysql-get-diagnostics.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>3</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-4332417558901192561</guid><pubDate>Mon, 29 Aug 2011 19:10:00 +0000</pubDate><atom:updated>2011-08-29T21:11:14.061+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>Explaining performance schema tables ... with pictures</title><description>&lt;h1&gt;
The problem&lt;/h1&gt;
For illustration, let's assume a MySQL server, with a couple of users (A, B, C, ...) who perform queries against some tables (T1, T2, etc) in the database.&lt;br /&gt;
Sooner of later, someone will want to know which user is performing which amount of table io against which table ... How can instrumentation help with that ?&lt;br /&gt;
&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;&lt;/th&gt;
  &lt;th&gt;T1&lt;/th&gt;
  &lt;th&gt;T2&lt;/th&gt;
  &lt;th&gt;T3&lt;/th&gt;
  &lt;th&gt;T4&lt;/th&gt;
  &lt;th&gt;T5&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User A&lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User B&lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User C&lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;??? &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h1&gt;
Performance schema aggregates&lt;/h1&gt;
&lt;br /&gt;
The performance schema provides different "summaries" tables, which aggregate statistics collected using different criteria.&lt;br /&gt;
&lt;h2&gt;
TABLE performance_schema.table_io_waits_summary_by_table&lt;/h2&gt;
&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;&lt;/th&gt;
  &lt;th&gt;T1&lt;/th&gt;
  &lt;th&gt;T2&lt;/th&gt;
  &lt;th&gt;T3&lt;/th&gt;
  &lt;th&gt;T4&lt;/th&gt;
  &lt;th&gt;T5&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User A&lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User B&lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User C&lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;??? &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="background-color: lime;"&gt;&lt;b&gt;TOTAL&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;ALL-T1&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;ALL-T2&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;ALL-T3&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;ALL-T4&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;ALL-T5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
This table shows directly the table io statistics, grouped by table.&lt;br /&gt;
In our picture, this is the TOTAL row.&lt;br /&gt;
&lt;h2&gt;
TABLE performance_schema.events_waits_summary_by_user_by_event_name&lt;/h2&gt;
&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;&lt;/th&gt;
  &lt;th&gt;T1&lt;/th&gt;
  &lt;th&gt;T2&lt;/th&gt;
  &lt;th&gt;T3&lt;/th&gt;
  &lt;th&gt;T4&lt;/th&gt;
  &lt;th&gt;T5&lt;/th&gt;
  &lt;th style="background-color: lime;"&gt;TOTAL&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User A&lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;ALL-A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User B&lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;ALL-B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User C&lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;??? &lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;ALL-C&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
This table shows statistics, but grouped by user instead of objects.&lt;br /&gt;
In our picture, this is the TOTAL column.&lt;br /&gt;
Many different statistics are collected (this is a _BY_EVENT_NAME table), so to get the table io statistics only, use a where clause such as "WHERE EVENT_NAME like 'wait/io/table/%' "&lt;br /&gt;
Oh, and by the way: this table is part of a new &lt;a href="http://forge.mysql.com/worklog/task.php?id=5378"&gt;feature&lt;/a&gt; merged recently in mysql-trunk.&lt;br /&gt;
The complete list of new tables delivered is:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;accounts&lt;/li&gt;
&lt;li&gt;users&lt;/li&gt;
&lt;li&gt;hosts&lt;/li&gt;
&lt;li&gt;events_waits_summary_by_account_by_event_name&lt;/li&gt;
&lt;li&gt;events_waits_summary_by_user_by_event_name&lt;/li&gt;
&lt;li&gt;events_waits_summary_by_host_by_event_name&lt;/li&gt;
&lt;li&gt;events_stages_summary_by_account_by_event_name&lt;/li&gt;
&lt;li&gt;events_stages_summary_by_user_by_event_name&lt;/li&gt;
&lt;li&gt;events_stages_summary_by_host_by_event_name&lt;/li&gt;
&lt;li&gt;events_statements_summary_by_account_by_event_name&lt;/li&gt;
&lt;li&gt;events_statements_summary_by_user_by_event_name&lt;/li&gt;
&lt;li&gt;events_statements_summary_by_host_by_event_name&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h1&gt;
Performance schema filters&lt;/h1&gt;
&lt;br /&gt;
The performance schema also provides tables used to limit the scope of events collected by the instrumentation. These filters can operate on different criteria as well.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
TABLE performance_schema.setup_actors&lt;/h2&gt;
&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;&lt;/th&gt;
  &lt;th&gt;T1&lt;/th&gt;
  &lt;th&gt;T2&lt;/th&gt;
  &lt;th&gt;T3&lt;/th&gt;
  &lt;th&gt;T4&lt;/th&gt;
  &lt;th&gt;T5&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="background-color: #999999;"&gt;&lt;b&gt;User A&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User B&lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="background-color: #999999;"&gt;&lt;b&gt;User C&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;??? &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Using table setup_actors, one can selectively enable or disable some users (rows in the array used in example, which are displayed in gray).&lt;br /&gt;
&lt;h2&gt;
TABLE performance_schema.setup_objects&lt;/h2&gt;
&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;&lt;/th&gt;
  &lt;th style="background-color: #999999;"&gt;T1&lt;/th&gt;
  &lt;th style="background-color: #999999;"&gt;T2&lt;/th&gt;
  &lt;th&gt;T3&lt;/th&gt;
  &lt;th style="background-color: #999999;"&gt;T4&lt;/th&gt;
  &lt;th style="background-color: #999999;"&gt;T5&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User A&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User B&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User C&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;??? &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Using table setup_objects, one can selectively enable or disable some SQL tables (columns in the array used in example, which are displayed in gray).&lt;br /&gt;
The table setup_objects now has a new column named "ENABLED", which was added recently in the trunk (another new &lt;a href="http://forge.mysql.com/worklog/task.php?id=5342"&gt;feature&lt;/a&gt;). This allows to easily enable "all tables except ...".&lt;br /&gt;
&lt;h1&gt;
On combining filters&lt;/h1&gt;
&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;&lt;/th&gt;
  &lt;th style="background-color: #999999;"&gt;T1&lt;/th&gt;
  &lt;th style="background-color: #999999;"&gt;T2&lt;/th&gt;
  &lt;th&gt;T3&lt;/th&gt;
  &lt;th&gt;T4&lt;/th&gt;
  &lt;th&gt;T5&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="background-color: #999999;"&gt;&lt;b&gt;User A&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User B&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User C&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;???&lt;/td&gt;
  &lt;td&gt;??? &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Using multiple filters at once is a great way to limit the scope of the queries instrumented. Assuming an homogeneous repartition of queries for example, collecting statistics for 2/3 of the users, for 3/5 of the tables, allows to reduce the amount of events collected by a factor 6/15.&lt;br /&gt;
The overhead of the table io instrumentation is directly affected here, with only 40% of the events processed.&lt;br /&gt;
&lt;h1&gt;
On using orthogonality&lt;/h1&gt;
&lt;br /&gt;
Using a filter in one dimension, and an aggregate in another dimension, allows to dive deeper and get a picture of only a "slice" of the server activity. This particular property of orthogonality is a key to the performance schema design. Examples of usage below.
&lt;br /&gt;
&lt;h2&gt;
What is this user doing ?&lt;/h2&gt;
&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;&lt;/th&gt;
  &lt;th&gt;T1&lt;/th&gt;
  &lt;th&gt;T2&lt;/th&gt;
  &lt;th&gt;T3&lt;/th&gt;
  &lt;th&gt;T4&lt;/th&gt;
  &lt;th&gt;T5&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="background-color: #999999;"&gt;&lt;b&gt;User A&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="background-color: lime;"&gt;&lt;b&gt;User B&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B1&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B2&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B3&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B4&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="background-color: #999999;"&gt;&lt;b&gt;User C&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;??? &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="background-color: lime;"&gt;&lt;b&gt;TOTAL&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B1&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B2&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B3&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B4&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Table setup_actors can isolate activity of a given user (or users). Aggregates by object will then show the detailed activity of the users(s) of interest on the database schema.
&lt;br /&gt;
&lt;h2&gt;
Who is touching this table ?&lt;/h2&gt;
&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;&lt;/th&gt;
  &lt;th style="background-color: #999999;"&gt;T1&lt;/th&gt;
  &lt;th style="background-color: #999999;"&gt;T2&lt;/th&gt;
  &lt;th style="background-color: lime;"&gt;T3&lt;/th&gt;
  &lt;th style="background-color: #999999;"&gt;T4&lt;/th&gt;
  &lt;th style="background-color: #999999;"&gt;T5&lt;/th&gt;
  &lt;th style="background-color: lime;"&gt;TOTAL&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User A&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;A3&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;A3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User B&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B3&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;B3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;User C&lt;/b&gt;&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;C3&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;???&lt;/td&gt;
  &lt;td style="background-color: #999999;"&gt;??? &lt;/td&gt;
  &lt;td style="background-color: lime;"&gt;C3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;

&lt;br /&gt;
Likewise, table setup_object can isolate activity on a given table (or set of tables). Aggregates by user will then show the detailed activity of different users on the table(s) of interest.
&lt;br /&gt;

&lt;h1&gt;
Last words&lt;/h1&gt;
&lt;br /&gt;
Please refer to the &lt;a href="http://dev.mysql.com/doc/refman/5.6/en/performance-schema.html"&gt; MySQL 5.6 performance schema documentation&lt;/a&gt; for more details.
&lt;br /&gt;
MySQL 5.6.3 is not a GA release, do not use in production. Subject to change without notice.
&lt;br /&gt;
-- Marc Alff, Oracle.
&lt;br /&gt;




</description><link>http://marcalff.blogspot.com/2011/08/explaining-performance-schema-tables.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-9219579590257617780</guid><pubDate>Fri, 24 Jun 2011 16:25:00 +0000</pubDate><atom:updated>2011-06-27T13:26:16.754+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>TUNING</category><category domain='http://www.blogger.com/atom/ns#'>OVERHEAD</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>Performance schema, overhead tuning</title><description>&lt;h1&gt;

Performance schema performance tuning&lt;/h1&gt;
One of the most important question users ask before deciding to use the performance schema is: what is the overhead ?  The underlying concern of course is to make sure deploying the performance schema does not negatively impact production ("First, do no harm").&lt;br /&gt;
The question is simple, and yet the answer is not so simple, as it depends on so many things.&lt;br /&gt;
As seen in some benchmarks done already, the overhead when using the performance schema can vary a lot, and in some cases really causes degradations.&lt;br /&gt;
A lot of time has been spent investigating the root causes (note the plural form) for the performance schema overhead in general, so I think it is a good time to share current findings.&lt;br /&gt;
&lt;h1&gt;

Server workload&lt;/h1&gt;
Analysing performances, and testing the effects of different code or configuration changes, can hardly be done in a vacuum.  That's where benchmarks come in.&lt;br /&gt;
The problem with benchmarks in general is that different benchmarks will produce different loads, and that a given code may perform very well under some conditions but poorly under others ...&lt;br /&gt;
One particular property of the performance schema is that, since it instruments the server itself, the load and behavior of the server:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;is there capacity left or is it saturated ?&lt;/li&gt;
&lt;li&gt;is it CPU bound or disk io bound ?,&lt;/li&gt;
&lt;li&gt;paging ?&lt;/li&gt;
&lt;li&gt;swaping ?&lt;/li&gt;
&lt;li&gt;contended in a specific place (query cache, table cache, innodb buffer pool, [insert your
  favorite here]) ?&lt;/li&gt;
&lt;/ul&gt;
directly influences the load put on the performance schema code:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;how many mutexes / rwlocks / cond events are detected ?&lt;/li&gt;
&lt;li&gt;how many file io events are detected ?&lt;/li&gt;
&lt;li&gt;how many table io / table lock events are detected ?&lt;/li&gt;
&lt;li&gt;how many stages / statements are detected ?&lt;/li&gt;
&lt;/ul&gt;
Given this load as input, the user configuration of the performance schema:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;the sizing of internal performance schema buffers,&lt;/li&gt;
&lt;li&gt;which instrument is enabled ?&lt;/li&gt;
&lt;li&gt;which instrument is timed ?&lt;/li&gt;
&lt;li&gt;which timer is used ?&lt;/li&gt;
&lt;li&gt;which consumer is enabled ?&lt;/li&gt;
&lt;li&gt;is there some filtering per user ? per host ? (table setup_actors)&lt;/li&gt;
&lt;li&gt;is there some filtering per object? (table setup_objects)&lt;/li&gt;
&lt;/ul&gt;
will decide what to do with the events seen:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;discard them,&lt;/li&gt;
&lt;li&gt;count them,&lt;/li&gt;
&lt;li&gt;time them,&lt;/li&gt;
&lt;li&gt;aggregate them, possibly with fancy aggregations,&lt;/li&gt;
&lt;/ul&gt;
all of which affects overhead.&lt;br /&gt;
To summarize, the overall system can be modeled as giant pipe, which consists of, in order:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;the client application and the generated application workload,&lt;/li&gt;
&lt;li&gt;the mysql server and the generated instrumentation workload,&lt;/li&gt;
&lt;li&gt;the performance schema and the generated statistics / overhead.&lt;/li&gt;
&lt;/ul&gt;
It is critical to understand how that pipe works to interpret results.&lt;br /&gt;
For example, if a client application is sending very few queries to the server, generating a very "small" load, a benchmark with or without the performance schema is not going to show any differences. To be meaningful, a benchmark (of the database) has to put a lot of pressure (on the database).  This is hardly a surprise, but here comes the interesting part.&lt;br /&gt;
Next, if a server is poorly configured for the application workload received, and if the server itself does not perform well for that load, the instrumentation workload on the performance schema will be "small". A properly configured server will execute more queries, transactions, etc, which will generate more events to instrument. To be meaningful, a benchmark (of the performance schema) has to put a lot of pressure (on the performance schema).&lt;br /&gt;
An immediate consequence is that benchmarks of the performance schema should disable the query cache: there are currently 474 instrumentation points in the server. If most executions paths bounce off of the query cache, stress will be on "wait/synch/mutex/sql/Query_cache::structure_guard_mutex" only, cutting off the load generated from the lower layers on the server code, such as the table io instrumentation, or the storage engines instrumentation.&lt;br /&gt;
A more subtle consequence is that every time a performance bottleneck in the server code is removed, either by a bug fix or by a better server tuning, server efficiency goes up, which increases the number of statements / transactions / whatever the benchmark metric is counting, that are executed. While this is good news for the server, it actually increases the
instrumentation workload for the performance schema.&lt;br /&gt;
In conclusion, and in my opinion, to interpret a performance schema benchmark, results should describe not only the overhead observed, but also the load seen that caused the overhead.  By load seen, I mean here the instrumentation load seen at the server / performance schema interface, since this is the real stress put on the performance schema code. The more details are available for each stage of the pipe, the better.&lt;br /&gt;
Time to dive into numbers then ...&lt;br /&gt;
&lt;h1&gt;

The trunk benchmark&lt;/h1&gt;
The load used for this analysis is sysbench, and more specifically the sysbench oltp read-only benchmark.&lt;br /&gt;
The reason this particular case was picked is not because I like the results on this one better.&lt;br /&gt;
The reasons are:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;sysbench oltp was the test used in &lt;a href="http://www.mysqlperformanceblog.com/2011/04/25/performance-schema-overhead/"&gt;previous benchmarks&lt;/a&gt;, and to reproduce the results
  (and analyse the reasons for overhead), it helps to be in similar
conditions,&lt;/li&gt;
&lt;li&gt;a read only, in memory only load eliminates a lot of noise from
  measurements, making analysis easier: the goal here is not to get a number
  (by "just" running a benchmark), it is to get an explanation for the
  number, so that the code can be improved,&lt;/li&gt;
&lt;li&gt;the performance schema code itself is "CPU only, user land only" code,
  as it does not make any io or any system call. A benchmark that shares the
  same characteristics seems more likely to provide interesting
  insight.&lt;/li&gt;
&lt;/ul&gt;
Time permitting, I hope to get to do the same analysis for other cases (sysbench read-write, dbt2, etc).&lt;br /&gt;
The test machine used is a 8 CPU / 32 GB Linux box,
so the test configuration is sized accordingly:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;for sysbench: --oltp-table-size=1000000&lt;/li&gt;
&lt;li&gt;for mysql my.cnf: innodb_buffer_pool_size = 12G&lt;/li&gt;
&lt;/ul&gt;
Historical note: testing done for this post started on a 8 CPU 16 GB machine, then moved to
another lab. The original configuration was not changed, hence the 12G
buffer pool only.&lt;br /&gt;
&lt;h1&gt;

The trunk results&lt;/h1&gt;
All results are for mysql-trunk (revno 3195, 2011-06-13), compiled in Release
configuration. This corresponds to the current code for mysql 5.6, which is still in development.&lt;br /&gt;
&lt;h2&gt;

Tests without the performance schema&lt;/h2&gt;
With this build, the performance instrumentation is not compiled.
All the computation of overhead expressed as percentages are relative to
this reference, which is used as the ultimate baseline.&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;Connections&lt;/th&gt; &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;CPU User (%)&lt;/th&gt; &lt;th&gt;CPU System (%)&lt;/th&gt; &lt;th&gt;CPU Idle (%)&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;1&lt;/td&gt; &lt;td&gt;807&lt;/td&gt; &lt;td&gt;10&lt;/td&gt; &lt;td&gt;2&lt;/td&gt; &lt;td&gt;88&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;2&lt;/td&gt; &lt;td&gt;1439&lt;/td&gt; &lt;td&gt;20&lt;/td&gt; &lt;td&gt;5&lt;/td&gt; &lt;td&gt;75&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;4&lt;/td&gt; &lt;td&gt;2610&lt;/td&gt; &lt;td&gt;40&lt;/td&gt; &lt;td&gt;10&lt;/td&gt; &lt;td&gt;50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;8&lt;/td&gt; &lt;td&gt;5086&lt;/td&gt; &lt;td&gt;84&lt;/td&gt; &lt;td&gt;14&lt;/td&gt; &lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;12&lt;/td&gt; &lt;td&gt;5037&lt;/td&gt; &lt;td&gt;84&lt;/td&gt; &lt;td&gt;15&lt;/td&gt; &lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;16&lt;/td&gt; &lt;td&gt;5038&lt;/td&gt; &lt;td&gt;85&lt;/td&gt; &lt;td&gt;15&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;32&lt;/td&gt; &lt;td&gt;4854&lt;/td&gt; &lt;td&gt;85&lt;/td&gt; &lt;td&gt;15&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;48&lt;/td&gt; &lt;td&gt;4762&lt;/td&gt; &lt;td&gt;85&lt;/td&gt; &lt;td&gt;15&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;64&lt;/td&gt; &lt;td&gt;4118 (*)&lt;/td&gt; &lt;td&gt;60&lt;/td&gt; &lt;td&gt;32&lt;/td&gt; &lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;128&lt;/td&gt; &lt;td&gt;3538 (*)&lt;/td&gt; &lt;td&gt;57&lt;/td&gt; &lt;td&gt;35&lt;/td&gt; &lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;256&lt;/td&gt; &lt;td&gt;1746 (*)&lt;/td&gt; &lt;td&gt;57&lt;/td&gt; &lt;td&gt;35&lt;/td&gt; &lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
The overall CPU statistics are collected by vmstat, and helps to qualify in
which mode the server is operating.&lt;br /&gt;
Looking at the overall shape of the performance curve, three different
operating modes can be observed:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Ramping up (1 to 8 connections)&lt;/li&gt;
&lt;li&gt;Peek efficiency (8 to 48 connections)&lt;/li&gt;
&lt;li&gt;Server progressive degradation (48 to infinity connections)&lt;/li&gt;
&lt;/ul&gt;
For a 8 core machine, this looks reasonable.&lt;br /&gt;
(*) A special note about results for 64 / 128 / 256 connections: the performance measured in this cases is not stable and can vary a lot (50 percent) between runs.
This is due to the machine saturation: at 256 connections, 256 threads are running in sysbench, plus 256+16 in mysqld, which makes 512+ active threads on a 8 core.
Numbers are posted for this case as well, to include this mode of operation in the analysis.&lt;br /&gt;
&lt;h2&gt;

Tests with the performance schema&lt;/h2&gt;
Now that we have established what the baseline looks like, executing the
same workload on the same hardware, under the same conditions gives the
following results. The CPU user / system / idle statistics from vmstat are
not repeated (the overall profile is the same) for brevity.&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;With performance schema&lt;/th&gt;
  &lt;th colspan="2"&gt;disabled&lt;/th&gt;
  &lt;th colspan="2"&gt;off&lt;/th&gt;
  &lt;th colspan="2"&gt;global (timed)&lt;/th&gt;
  &lt;th colspan="2"&gt;thread (timed)&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Connections&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;796&lt;/td&gt; &lt;td&gt;1.36&lt;/td&gt;
  &lt;td&gt;775&lt;/td&gt; &lt;td&gt;3.97&lt;/td&gt;
  &lt;td&gt;684&lt;/td&gt; &lt;td&gt;15.24&lt;/td&gt;
  &lt;td&gt;681&lt;/td&gt; &lt;td&gt;15.61&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1409&lt;/td&gt; &lt;td&gt;2.08&lt;/td&gt;
  &lt;td&gt;1349&lt;/td&gt; &lt;td&gt;6.25&lt;/td&gt;
  &lt;td&gt;1198&lt;/td&gt; &lt;td&gt;16.75&lt;/td&gt;
  &lt;td&gt;1191&lt;/td&gt; &lt;td&gt;17.23&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;4&lt;/td&gt;
  &lt;td&gt;2544&lt;/td&gt; &lt;td&gt;2.53&lt;/td&gt;
  &lt;td&gt;4634&lt;/td&gt; &lt;td&gt;5.86&lt;/td&gt;
  &lt;td&gt;2115&lt;/td&gt; &lt;td&gt;18.97&lt;/td&gt;
  &lt;td&gt;2114&lt;/td&gt; &lt;td&gt;19.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;8&lt;/td&gt;
  &lt;td&gt;4844&lt;/td&gt; &lt;td&gt;4.76&lt;/td&gt;
  &lt;td&gt;4634&lt;/td&gt; &lt;td&gt;8.89&lt;/td&gt;
  &lt;td&gt;3974&lt;/td&gt; &lt;td&gt;21.86&lt;/td&gt;
  &lt;td&gt;3913&lt;/td&gt; &lt;td&gt;23.06&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;12&lt;/td&gt;
  &lt;td&gt;4850&lt;/td&gt; &lt;td&gt;3.71&lt;/td&gt;
  &lt;td&gt;4662&lt;/td&gt; &lt;td&gt;7.44&lt;/td&gt;
  &lt;td&gt;4020&lt;/td&gt; &lt;td&gt;20.19&lt;/td&gt;
  &lt;td&gt;3979&lt;/td&gt; &lt;td&gt;21.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;16&lt;/td&gt;
  &lt;td&gt;4847&lt;/td&gt; &lt;td&gt;3.79&lt;/td&gt;
  &lt;td&gt;4676&lt;/td&gt; &lt;td&gt;7.19&lt;/td&gt;
  &lt;td&gt;4051&lt;/td&gt; &lt;td&gt;19.59&lt;/td&gt;
  &lt;td&gt;4020&lt;/td&gt; &lt;td&gt;20.21&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;32&lt;/td&gt;
  &lt;td&gt;4676&lt;/td&gt; &lt;td&gt;3.61&lt;/td&gt;
  &lt;td&gt;4485&lt;/td&gt; &lt;td&gt;7.60&lt;/td&gt;
  &lt;td&gt;3851&lt;/td&gt; &lt;td&gt;20.66&lt;/td&gt;
  &lt;td&gt;3789&lt;/td&gt; &lt;td&gt;21.94&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;48&lt;/td&gt;
  &lt;td&gt;4582&lt;/td&gt; &lt;td&gt;3.78&lt;/td&gt;
  &lt;td&gt;4384&lt;/td&gt; &lt;td&gt;7.94&lt;/td&gt;
  &lt;td&gt;3759&lt;/td&gt; &lt;td&gt;21.06&lt;/td&gt;
  &lt;td&gt;3692&lt;/td&gt; &lt;td&gt;22.47&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;64 (*)&lt;/td&gt;
  &lt;td&gt;2548&lt;/td&gt; &lt;td&gt;38.13&lt;/td&gt;
  &lt;td&gt;3048&lt;/td&gt; &lt;td&gt;25.98&lt;/td&gt;
  &lt;td&gt;3392&lt;/td&gt; &lt;td&gt;17.63&lt;/td&gt;
  &lt;td&gt;3286&lt;/td&gt; &lt;td&gt;20.20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;128 (*)&lt;/td&gt;
  &lt;td&gt;2035&lt;/td&gt; &lt;td&gt;42.48&lt;/td&gt;
  &lt;td&gt;2007&lt;/td&gt; &lt;td&gt;43.27&lt;/td&gt;
  &lt;td&gt;1938&lt;/td&gt; &lt;td&gt;45.22&lt;/td&gt;
  &lt;td&gt;1917&lt;/td&gt; &lt;td&gt;45.82&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;256 (*)&lt;/td&gt;
  &lt;td&gt;1745&lt;/td&gt; &lt;td&gt;0.06&lt;/td&gt;
  &lt;td&gt;1697&lt;/td&gt; &lt;td&gt;2.81&lt;/td&gt;
  &lt;td&gt;1662&lt;/td&gt; &lt;td&gt;4.81&lt;/td&gt;
  &lt;td&gt;1624&lt;/td&gt; &lt;td&gt;6.99&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
(*) The same comment about results stability applies here. Because the results are unstable with great variations, the overhead computed after normalization on a unstable baseline gives meaningless results.&lt;br /&gt;
&lt;h2&gt;

Analysis&lt;/h2&gt;
Overall, the overhead in the most basic configuration, with all instruments enabled and only the global instrumentation consumer enabled, is at 20 percent already.&lt;br /&gt;
This is a lot. Looking in more details at these results, it appears that:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Adding the thread instrumentation consumer (to get statistics per thread) does only marginally increase overhead:
at 8 connections, the overhead goes from 21.86% to 23.06%.&lt;/li&gt;
&lt;li&gt;The overhead depends on the number of connections. It is progressive in the 1-8 connections range, peaks at 8 connections, then is both stable and significant at 8-48 connections.&lt;/li&gt;
&lt;li&gt;Peak TPS without the performance schema was at 8 connections. With the performance schema, it seems to move to 12 or even 16 connections.&lt;/li&gt;
&lt;/ul&gt;
To understand the root cause for this 20% toll, the following measurements are also instructive:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;With the performance schema enabled but all instruments disabled (configuration "off"), the overhead is at ~8%. For code doing nothing, this is actually quite high.&lt;/li&gt;
&lt;li&gt;When the performance schema is disabled at startup time (configuration "disabled"), the overhead is at ~4%. This configuration is not very useful from a functional point of view, but from a technical point of view it executes a code path which is a subset of the configuration "off". That makes the numbers collected useful. &lt;/li&gt;
&lt;/ul&gt;
Based on this, overhead seems to originate from, roughly:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;compiling with the performance schema (configuration "disabled"): ~4% cost,&lt;/li&gt;
&lt;li&gt;starting with the performance schema (configuration "off"): additional ~4% cost,&lt;/li&gt;
&lt;li&gt;enabling the global consumer only (configuration "global (timed)"): additional ~12% cost,&lt;/li&gt;
&lt;li&gt;adding the thread consumer only (configuration "global (timed)"): additional ~1% cost&lt;/li&gt;
&lt;/ul&gt;
To understand better which code is executed, and how often, let's use the performance schema itself to get some insight on the server execution. After all, that is precisely what the performance schema is for.&lt;br /&gt;
Using the "thread (timed)" configuration, with the assumption that the instrumentation does not distort the workload, and looking at details for 8 connections, which is chosen because it corresponds to the peak performance without the performance schema, statistics collected are as follows below.&lt;br /&gt;
&lt;h3&gt;

Total number of wait events.&lt;/h3&gt;
&lt;pre&gt;mysql&amp;gt; select sum(count_star), sum(sum_timer_wait)
    -&amp;gt;   from performance_schema.events_waits_summary_global_by_event_name;
+-----------------+---------------------+
| sum(count_star) | sum(sum_timer_wait) |
+-----------------+---------------------+
|      1098658477 |     797822128662705 |
+-----------------+---------------------+
1 row in set (1.79 sec)
&lt;/pre&gt;
&lt;h3&gt;

Top waits, by count&lt;/h3&gt;
&lt;pre&gt;mysql&amp;gt; select * from performance_schema.events_waits_summary_global_by_event_name
    -&amp;gt;   where count_star&amp;gt;0 order by count_star desc limit 25;
+-----------------------------------------------+------------+-----------------+----------------+----------------+----------------+
| EVENT_NAME                                    | COUNT_STAR | SUM_TIMER_WAIT  | MIN_TIMER_WAIT | AVG_TIMER_WAIT | MAX_TIMER_WAIT |
+-----------------------------------------------+------------+-----------------+----------------+----------------+----------------+
| wait/io/table/sql/handler                     |  482492695 | 583215424951365 |          42210 |        1208680 |     7913678535 |
| wait/synch/mutex/innodb/srv_conc_mutex        |  265080324 | 142377797253015 |          30150 |         537005 |     1862766495 |
| wait/synch/mutex/sql/THD::LOCK_thd_data       |  122077261 |   6519294560295 |          30150 |          53265 |     1072076715 |
| wait/synch/rwlock/innodb/hash table locks     |   38409624 |   5420427797475 |          27135 |         141035 |      360901530 |
| wait/synch/mutex/innodb/read_view_mutex       |   32554195 |   6146001298890 |          24120 |         188605 |     1011083265 |
| wait/synch/mutex/sql/LOCK_open                |   32553870 |   9359193544965 |          30150 |         287430 |     1080446355 |
| wait/lock/table/sql/handler                   |   32553724 |  20576707870950 |          99495 |         631810 |     1083789990 |
| wait/synch/mutex/mysys/THR_LOCK::mutex        |   32553724 |   6964485402105 |          30150 |         213730 |     3022857090 |
| wait/synch/rwlock/innodb/trx_sys_lock         |   18592602 |   5270410352025 |          42210 |         283410 |     1622682045 |
| wait/synch/rwlock/sql/LOCK_grant              |   16276408 |   3502306526580 |          51255 |         215070 |      892225935 |
| wait/synch/rwlock/innodb/btr_search_latch     |   16198467 |   4144473779535 |          27135 |         255605 |     1048297410 |
| wait/synch/rwlock/sql/MDL_lock::rwlock        |    2325412 |    524010714480 |          54270 |         225120 |       36433260 |
| wait/synch/mutex/mysys/BITMAP::mutex          |    2325268 |    409667867595 |          42210 |         175875 |      908214480 |
| wait/synch/mutex/innodb/trx_mutex             |    1163261 |     32488536510 |          24120 |          27805 |        7419915 |
| wait/synch/mutex/sql/MDL_map::mutex           |    1162780 |    274705866855 |          36180 |         236175 |      133772535 |
| wait/synch/mutex/sql/LOCK_plugin              |    1162673 |    212769433395 |          33165 |         182910 |      791328960 |
| wait/synch/mutex/innodb/lock_mutex            |    1162633 |    145945057815 |          39195 |         125290 |       14173515 |
| wait/synch/mutex/innodb/log_sys_mutex         |       7757 |      2441752020 |          27135 |         314565 |     1239502680 |
| wait/synch/mutex/innodb/os_mutex              |       2490 |       271684665 |          30150 |         108875 |       17423685 |
| wait/synch/mutex/innodb/fil_system_mutex      |       1402 |       146559150 |          24120 |         104520 |        5538555 |
| wait/synch/mutex/innodb/flush_list_mutex      |        607 |        96362415 |          33165 |         158455 |         346725 |
| wait/io/file/innodb/innodb_log_file           |        600 |   2693980326195 |       23094900 |     4489967145 |   819050374485 |
| wait/synch/mutex/innodb/buf_pool_mutex        |        516 |        40862295 |          27135 |          79060 |         521595 |
| wait/synch/mutex/innodb/log_flush_order_mutex |        473 |        49503285 |          33165 |         104520 |         397980 |
| wait/synch/mutex/innodb/lock_wait_mutex       |        428 |        71949960 |          63315 |         167835 |        1706490 |
+-----------------------------------------------+------------+-----------------+----------------+----------------+----------------+
25 rows in set (1.79 sec)
&lt;/pre&gt;
&lt;h3&gt;

Top waits, by time&lt;/h3&gt;
&lt;pre&gt;mysql&amp;gt; select * from performance_schema.events_waits_summary_global_by_event_name
    -&amp;gt;   where count_star&amp;gt;0 order by sum_timer_wait desc limit 25;
+-------------------------------------------+------------+-----------------+----------------+----------------+----------------+
| EVENT_NAME                                | COUNT_STAR | SUM_TIMER_WAIT  | MIN_TIMER_WAIT | AVG_TIMER_WAIT | MAX_TIMER_WAIT |
+-------------------------------------------+------------+-----------------+----------------+----------------+----------------+
| wait/io/table/sql/handler                 |  482492695 | 583215424951365 |          42210 |        1208680 |     7913678535 |
| wait/synch/mutex/innodb/srv_conc_mutex    |  265080324 | 142377797253015 |          30150 |         537005 |     1862766495 |
| wait/lock/table/sql/handler               |   32553724 |  20576707870950 |          99495 |         631810 |     1083789990 |
| wait/synch/mutex/sql/LOCK_open            |   32553870 |   9359193544965 |          30150 |         287430 |     1080446355 |
| wait/synch/mutex/mysys/THR_LOCK::mutex    |   32553724 |   6964485402105 |          30150 |         213730 |     3022857090 |
| wait/synch/mutex/sql/THD::LOCK_thd_data   |  122077261 |   6519294560295 |          30150 |          53265 |     1072076715 |
| wait/synch/mutex/innodb/read_view_mutex   |   32554342 |   6146010024300 |          24120 |         188605 |     1011083265 |
| wait/synch/rwlock/innodb/hash table locks |   38409624 |   5420427797475 |          27135 |         141035 |      360901530 |
| wait/synch/rwlock/innodb/trx_sys_lock     |   18592651 |   5270414135850 |          42210 |         283410 |     1622682045 |
| wait/synch/rwlock/innodb/btr_search_latch |   16198467 |   4144473779535 |          27135 |         255605 |     1048297410 |
| wait/synch/rwlock/sql/LOCK_grant          |   16276408 |   3502306526580 |          51255 |         215070 |      892225935 |
| wait/io/file/innodb/innodb_log_file       |        600 |   2693980326195 |       23094900 |     4489967145 |   819050374485 |
| wait/synch/rwlock/sql/MDL_lock::rwlock    |    2325412 |    524010714480 |          54270 |         225120 |       36433260 |
| wait/synch/mutex/mysys/BITMAP::mutex      |    2325268 |    409667867595 |          42210 |         175875 |      908214480 |
| wait/synch/mutex/sql/MDL_map::mutex       |    1162780 |    274705866855 |          36180 |         236175 |      133772535 |
| wait/synch/mutex/sql/LOCK_plugin          |    1162673 |    212769433395 |          33165 |         182910 |      791328960 |
| wait/synch/mutex/innodb/lock_mutex        |    1162633 |    145945057815 |          39195 |         125290 |       14173515 |
| wait/synch/mutex/innodb/trx_mutex         |    1163457 |     32497638795 |          24120 |          27805 |        7419915 |
| wait/io/file/innodb/innodb_data_file      |          8 |     23031533745 |       54936315 |     2878941425 |     7430889600 |
| wait/synch/rwlock/innodb/checkpoint_lock  |          4 |      5048894880 |         250245 |     1262223720 |     2745088155 |
| wait/synch/mutex/innodb/log_sys_mutex     |       8095 |      2471021640 |          27135 |         305185 |     1239502680 |
| wait/synch/mutex/sql/LOCK_thread_count    |         31 |       830150100 |          30150 |       26778895 |      235748880 |
| wait/synch/mutex/innodb/os_mutex          |       2539 |       276339825 |          30150 |         108540 |       17423685 |
| wait/synch/mutex/innodb/fil_system_mutex  |       1451 |       149064615 |          24120 |         102510 |        5538555 |
| wait/synch/mutex/innodb/flush_list_mutex  |        704 |       111835395 |          33165 |         158790 |         346725 |
+-------------------------------------------+------------+-----------------+----------------+----------------+----------------+
25 rows in set (1.79 sec)
&lt;/pre&gt;
&lt;h3&gt;

Total number of stage events&lt;/h3&gt;
&lt;pre&gt;mysql&amp;gt; select sum(count_star), sum(sum_timer_wait)
    -&amp;gt;   from performance_schema.events_stages_summary_global_by_event_name;
+-----------------+---------------------+
| sum(count_star) | sum(sum_timer_wait) |
+-----------------+---------------------+
|       244153447 |    2263079088326000 |
+-----------------+---------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;
&lt;h3&gt;

Top stages, by count&lt;/h3&gt;
&lt;pre&gt;mysql&amp;gt; select * from performance_schema.events_stages_summary_global_by_event_name
    -&amp;gt;   where count_star&amp;gt;0 order by count_star desc limit 25;
+--------------------------------+------------+-----------------+----------------+----------------+----------------+
| EVENT_NAME                     | COUNT_STAR | SUM_TIMER_WAIT  | MIN_TIMER_WAIT | AVG_TIMER_WAIT | MAX_TIMER_WAIT |
+--------------------------------+------------+-----------------+----------------+----------------+----------------+
| stage/sql/init                 |   34879169 | 157347558824000 |        2374000 |        4511000 |     1685373000 |
| stage/sql/cleaning up          |   18602306 |  25263461317000 |         628000 |        1358000 |     2278265000 |
| stage/sql/closing tables       |   18602129 | 384870074281000 |         628000 |       20689000 |     4374172000 |
| stage/sql/query end            |   18602129 |  23815226118000 |         698000 |        1280000 |     1674268000 |
| stage/sql/checking permissions |   16276937 |  37278853417000 |        1327000 |        2290000 |     1734543000 |
| stage/sql/Opening tables       |   16276936 |  91344126412000 |        3352000 |        5611000 |     1641511000 |
| stage/sql/executing            |   16276863 |  15264844128000 |         628000 |         937000 |     1097577000 |
| stage/sql/statistics           |   16276863 | 325924010836000 |        6495000 |       20023000 |     3296152000 |
| stage/sql/Sending data         |   16276863 | 548279995436000 |        2794000 |       33684000 |     6805393000 |
| stage/sql/System lock          |   16276863 |  68298443425000 |        2444000 |        4196000 |     1102675000 |
| stage/sql/preparing            |   16276863 |  40997524468000 |        1676000 |        2518000 |     1090453000 |
| stage/sql/optimizing           |   16276863 |  31599629407000 |        1606000 |        1941000 |     1093176000 |
| stage/sql/end                  |   16276863 |  17257774496000 |         768000 |        1060000 |     1070408000 |
| stage/sql/Sorting result       |    2325266 | 270070871391000 |        7264000 |      116146000 |     3214855000 |
| stage/sql/removing tmp table   |    1162634 |  15392269553000 |        9359000 |       13239000 |      904741000 |
| stage/sql/freeing items        |    1162634 |  15041751826000 |        3143000 |       12937000 |     1106237000 |
| stage/sql/Creating tmp table   |    1162633 |  14681955665000 |        9568000 |       12628000 |     1092898000 |
| stage/sql/Copying to tmp table |    1162633 | 180350717326000 |      116008000 |      155122000 |     8074224000 |
+--------------------------------+------------+-----------------+----------------+----------------+----------------+
18 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;h3&gt;

Top stages, by time&lt;/h3&gt;
&lt;pre&gt;mysql&amp;gt; select * from performance_schema.events_stages_summary_global_by_event_name
    -&amp;gt;   where count_star&amp;gt;0 order by sum_timer_wait desc limit 25;
+--------------------------------+------------+-----------------+----------------+----------------+----------------+
| EVENT_NAME                     | COUNT_STAR | SUM_TIMER_WAIT  | MIN_TIMER_WAIT | AVG_TIMER_WAIT | MAX_TIMER_WAIT |
+--------------------------------+------------+-----------------+----------------+----------------+----------------+
| stage/sql/Sending data         |   16276863 | 548279995436000 |        2794000 |       33684000 |     6805393000 |
| stage/sql/closing tables       |   18602129 | 384870074281000 |         628000 |       20689000 |     4374172000 |
| stage/sql/statistics           |   16276863 | 325924010836000 |        6495000 |       20023000 |     3296152000 |
| stage/sql/Sorting result       |    2325266 | 270070871391000 |        7264000 |      116146000 |     3214855000 |
| stage/sql/Copying to tmp table |    1162633 | 180350717326000 |      116008000 |      155122000 |     8074224000 |
| stage/sql/init                 |   34879169 | 157347558824000 |        2374000 |        4511000 |     1685373000 |
| stage/sql/Opening tables       |   16276936 |  91344126412000 |        3352000 |        5611000 |     1641511000 |
| stage/sql/System lock          |   16276863 |  68298443425000 |        2444000 |        4196000 |     1102675000 |
| stage/sql/preparing            |   16276863 |  40997524468000 |        1676000 |        2518000 |     1090453000 |
| stage/sql/checking permissions |   16276937 |  37278853417000 |        1327000 |        2290000 |     1734543000 |
| stage/sql/optimizing           |   16276863 |  31599629407000 |        1606000 |        1941000 |     1093176000 |
| stage/sql/cleaning up          |   18602306 |  25263461317000 |         628000 |        1358000 |     2278265000 |
| stage/sql/query end            |   18602129 |  23815226118000 |         698000 |        1280000 |     1674268000 |
| stage/sql/end                  |   16276863 |  17257774496000 |         768000 |        1060000 |     1070408000 |
| stage/sql/removing tmp table   |    1162634 |  15392269553000 |        9359000 |       13239000 |      904741000 |
| stage/sql/executing            |   16276863 |  15264844128000 |         628000 |         937000 |     1097577000 |
| stage/sql/freeing items        |    1162634 |  15041751826000 |        3143000 |       12937000 |     1106237000 |
| stage/sql/Creating tmp table   |    1162633 |  14681955665000 |        9568000 |       12628000 |     1092898000 |
+--------------------------------+------------+-----------------+----------------+----------------+----------------+
18 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;h3&gt;

Total number of statement events&lt;/h3&gt;
&lt;pre&gt;mysql&amp;gt; select sum(count_star), sum(sum_timer_wait)
    -&amp;gt;   from performance_schema.events_statements_summary_global_by_event_name;
+-----------------+---------------------+
| sum(count_star) | sum(sum_timer_wait) |
+-----------------+---------------------+
|        18602306 |    2293686457711000 |
+-----------------+---------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;
&lt;h3&gt;

Top statements, by count&lt;/h3&gt;
&lt;pre&gt;mysql&amp;gt; select event_name, count_star, sum_timer_wait
         from performance_schema.events_statements_summary_global_by_event_name
         where count_star&amp;gt;0 order by count_star desc limit 25;
+---------------------------------+------------+------------------+
| event_name                      | count_star | sum_timer_wait   |
+---------------------------------+------------+------------------+
| statement/com/Execute           |   17439495 | 2267764442472000 |
| statement/sql/begin             |    1162633 |   25914627564000 |
| statement/com/Prepare           |         88 |       3041856000 |
| statement/com/Close stmt        |         80 |        729649000 |
| statement/com/Quit              |          9 |         47910000 |
| statement/sql/show_table_status |          1 |       3568260000 |
+---------------------------------+------------+------------------+
6 rows in set (0.00 sec)

&lt;/pre&gt;
&lt;h3&gt;

Top statements, by time&lt;/h3&gt;
&lt;pre&gt;mysql&amp;gt; select event_name, count_star, sum_timer_wait
         from performance_schema.events_statements_summary_global_by_event_name
         where count_star&amp;gt;0 order by sum_timer_wait desc limit 25;
+---------------------------------+------------+------------------+
| event_name                      | count_star | sum_timer_wait   |
+---------------------------------+------------+------------------+
| statement/com/Execute           |   17439495 | 2267764442472000 |
| statement/sql/begin             |    1162633 |   25914627564000 |
| statement/sql/show_table_status |          1 |       3568260000 |
| statement/com/Prepare           |         88 |       3041856000 |
| statement/com/Close stmt        |         80 |        729649000 |
| statement/com/Quit              |          9 |         47910000 |
+---------------------------------+------------+------------------+
6 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;h3&gt;

Timer statistics&lt;/h3&gt;
&lt;pre&gt;mysql&amp;gt; select * from performance_schema.setup_timers;
+-----------+------------+
| NAME      | TIMER_NAME |
+-----------+------------+
| wait      | CYCLE      |
| stage     | NANOSECOND |
| statement | NANOSECOND |
+-----------+------------+
3 rows in set (0.00 sec)

mysql&amp;gt; select * from performance_schema.performance_timers;
+-------------+-----------------+------------------+----------------+
| TIMER_NAME  | TIMER_FREQUENCY | TIMER_RESOLUTION | TIMER_OVERHEAD |
+-------------+-----------------+------------------+----------------+
| CYCLE       |      2982179104 |                1 |             36 |
| NANOSECOND  |      1000000000 |                1 |           1404 |
| MICROSECOND |         1000000 |                1 |           1422 |
| MILLISECOND |            1034 |                1 |           1431 |
| TICK        |             104 |                1 |            774 |
+-------------+-----------------+------------------+----------------+
5 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;h3&gt;

Interpreting results&lt;/h3&gt;
Let's do some basic math to understand what this means ...&lt;br /&gt;
The total number of wait events collected is "1098658477". That's a big number. In a more readable form, it reads "1,098,658,477".
That still is a big number. In plain English, it is &lt;b&gt;1 Billion&lt;/b&gt;, with a &lt;b&gt;B&lt;/b&gt;. This was for a 5 minutes (300 sec) run, and all the statistics were truncated just before the sysbench load, so only the load itself is counted here.&lt;br /&gt;
Events collection rates (in number or events per seconds) are then:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;3662194 waits/sec, or 3.6 M waits/sec&lt;/li&gt;
&lt;li&gt;813844 stages/sec, or 813 K stages/sec&lt;/li&gt;
&lt;li&gt;62007 statements/sec, or 62 K statements/sec&lt;/li&gt;
&lt;/ul&gt;
These numbers are actually mind blowing. Keep in mind that there is no sampling involved. When each and every one of these events is collected, the performance schema time the event, and add statistics to the proper counter for the object and the thread involved, so that statistics per object, per table, per thread, etc, are available.&lt;br /&gt;
For what it is worth, we also have 13 stages per statements, and 59 waits per statements, on average.&lt;br /&gt;
Based on the top wait events, we can verify that this workload is indeed CPU bound and read only, since no file io are involved&lt;br /&gt;
An important point to note is that "wait/io/table" here represents table IO, as seen at the SQL layer / storage engine interface. A table IO event will time the code executed overall inside the storage engine, so it basically is the sum of the CPU time spent inside the engine and the waits blocking the storage engine. Having a big number reported in table io is expected.&lt;br /&gt;
Given the rate of collection for this load, 3.6 M waits/sec, the overhead in the performance schema is not caused by a big, rarely invoked, slow function, but rather by very frequent calls to very short functions.&lt;br /&gt;
With such a number of events, timing events cause a huge number of timer invocations.&lt;br /&gt;
For waits, the timer used is the cycle timer (see table performance_schema.setup_timers). For the CYCLE timer, the timer overhead alone, expressed in cycles, is 36 for this machine (see table performance_schema.performance_timers).&lt;br /&gt;
With 1098658477 events, 2 timer invocation per event, that makes 79103410344 cycles spent timing waits.&lt;br /&gt;
Given a CPU frequency of 2982179104 or 2.9 GHz, this represents 26.5224 seconds of CPU in a 300 seconds benchmark.&lt;br /&gt;
During this 300 sec benchmark, top reports that mysqld (the server process) consumes 723 percents of CPU (this is a 8 core, but sysbench alone eats 70 percent), so the overall CPU used by the server is 2169 sec. An overhead of 26 sec / 2169 sec represents 1.2 percent of CPU power, just timing waits.&lt;br /&gt;
Let's do the same math for stages and statements. They both use the same timer, nanoseconds.&lt;br /&gt;
With 244153447 stages, 2 timers per stage, 1404 cycles per timer, we have 685582879176 cycles or 229.8933 sec of CPU.&lt;br /&gt;
With 18602306 statements, 2 timers per stage, 1404 cycles per timer, we have 52235275248 cycles or 17.5158 sec of CPU. &lt;br /&gt;
Ouch ! That makes 229.8933+17.5158 or 247.4091 seconds of CPU calling the nanosecond timer. In terms of overhead, 247 seconds taken from 2169 represents 11.4 percent of mysqld spent for the nanosecond timer alone.&lt;br /&gt;
The bottom line is, this usage of the nanosecond timer is killing the performance. Now, why ? Intuitively, one would think that collecting and timing waits at a rate of 3.6 M / sec is more consuming than doing the same thing for stages and statements, at a rate of 813 K / sec and 62 K / sec respectively.&lt;br /&gt;
The root cause for this bad performances is hidden in plain sight, exposed by the performance_timers table.&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; select * from performance_schema.performance_timers;
+-------------+-----------------+------------------+----------------+
| TIMER_NAME  | TIMER_FREQUENCY | TIMER_RESOLUTION | TIMER_OVERHEAD |
+-------------+-----------------+------------------+----------------+
| CYCLE       |      2982179104 |                1 |             36 |
| NANOSECOND  |      1000000000 |                1 |           1404 | &amp;lt;-- Really ? This is HUGE !
| MICROSECOND |         1000000 |                1 |           1422 |
| MILLISECOND |            1034 |                1 |           1431 |
| TICK        |             104 |                1 |            774 |
+-------------+-----------------+------------------+----------------+
5 rows in set (0.00 sec)
&lt;/pre&gt;
This is actually the first time I find a machine where the overhead for the NANOSECOND, MICROSECOND and MILLISECOND timer is so high&lt;br /&gt;
Some details about the machine used ...&lt;br /&gt;
&lt;pre&gt;malff@tyr03:~&amp;gt;more /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5450  @ 3.00GHz
stepping        : 6
cpu MHz         : 2992.227
cache size      : 6144 KB
...
There are 8 cores total, all identical.
&lt;/pre&gt;
Timer details&lt;br /&gt;
&lt;pre&gt;malff@tyr03:withpfs&amp;gt;./unittest/mysys/my_rdtsc-t
1..11
# ----- Routine ---------------
# myt.cycles.routine          :             2 &amp;lt;-- RDTSC
# myt.nanoseconds.routine     :            11 &amp;lt;-- CLOCK_GETTIME
# myt.microseconds.routine    :            13
# myt.milliseconds.routine    :            18
# myt.ticks.routine           :            17
# ----- Frequency -------------
# myt.cycles.frequency        :    2986029850
# myt.nanoseconds.frequency   :    1000000000
# myt.microseconds.frequency  :       1000000
# myt.milliseconds.frequency  :          1035
# myt.ticks.frequency         :           104
# ----- Resolution ------------
# myt.cycles.resolution       :             1
# myt.nanoseconds.resolution  :             1
# myt.microseconds.resolution :             1
# myt.milliseconds.resolution :             1
# myt.ticks.resolution        :             1
# ----- Overhead --------------
# myt.cycles.overhead         :            36
# myt.nanoseconds.overhead    :          1404 &amp;lt;-- Ouch
# myt.microseconds.overhead   :          1422
# myt.milliseconds.overhead   :          1431
# myt.ticks.overhead          :           765
...
&lt;/pre&gt;
&lt;pre&gt;malff@tyr03:~&amp;gt;uname -a
Linux tyr03 2.6.32-100.28.17.el6.x86_64 #1 SMP Mon May 23 04:37:16 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
&lt;/pre&gt;
To have a point of comparison, the following are taken from a 4 core 8 Gb machine (my now several years old desktop)&lt;br /&gt;
&lt;pre&gt;mysql&amp;gt; select * from performance_timers;
+-------------+-----------------+------------------+----------------+
| TIMER_NAME  | TIMER_FREQUENCY | TIMER_RESOLUTION | TIMER_OVERHEAD |
+-------------+-----------------+------------------+----------------+
| CYCLE       |      2831810945 |                1 |             34 | &amp;lt;-- Marc desktop
| NANOSECOND  |      1000000000 |                1 |            102 | &amp;lt;-- Marc desktop
| MICROSECOND |         1000000 |                1 |            111 |
| MILLISECOND |            1037 |                1 |            127 |
| TICK        |             105 |                1 |            493 |
+-------------+-----------------+------------------+----------------+
5 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;pre&gt;malff@linux-8edv:~&amp;gt; more /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Core(TM)2 Quad CPU    Q9550  @ 2.83GHz
stepping        : 10
cpu MHz         : 2833.000
cache size      : 6144 KB
...
&lt;/pre&gt;
&lt;pre&gt;malff@linux-8edv:~&amp;gt; uname -a
Linux linux-8edv 2.6.37.6-0.5-desktop #1 SMP PREEMPT 2011-04-25 21:48:33 +0200 x86_64 x86_64 x86_64 GNU/Linux
&lt;/pre&gt;
Both the lab machine (tyr03) and my desktop have an Intel processor, and they happen to even be of the same family (6) and model (23),
only the model name differ (Xeon E5450 vs Core 2 Quad Q9550).&lt;br /&gt;
The CYCLE timer is implemented using RDTSC in both cases, and the overheads measured are very similar, with 36 and 34 cycles.&lt;br /&gt;
Implementation of the CYCLE timer is in &lt;a href="http://bazaar.launchpad.net/%7Emysql/mysql-server/mysql-trunk/view/head:/mysys/my_rdtsc.c#L134"&gt;my_timer_cycles()&lt;/a&gt; in mysys.&lt;br /&gt;
Details about the RDTSC instruction can be found in the &lt;a href="http://www.intel.com/Assets/PDF/manual/248966.pdf"&gt;processor spec&lt;/a&gt;, page C-32 (722). Family 6 model 23 is CPUID 06_17H.&lt;br /&gt;
For the nanoseconds timer, it is implemented in &lt;a href="http://bazaar.launchpad.net/%7Emysql/mysql-server/mysql-trunk/view/head:/mysys/my_rdtsc.c#L247"&gt;my_timer_nanoseconds()&lt;/a&gt; in both cases with a call to clock_gettime(CLOCK_REALTIME), in both cases on Linux 2.6.&lt;br /&gt;
The lab machine has a Linux 2.6.32 kernel, while the desktop has Linux 2.6.37.&lt;br /&gt;
The exact root cause of this huge difference in overhead (1404 vs 102) has not been explained yet.&lt;br /&gt;
In the mean time, given the cost of the nanosecond timer, maybe the performance schema overhead could be reduced by not timing events or timing them with the cycle timer.&lt;br /&gt;
This is worth a new set of measurements, still for mysql-trunk ...&lt;br /&gt;
&lt;h1&gt;

The trunk benchmark, revisited&lt;/h1&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;With performance schema&lt;/th&gt;
  &lt;th colspan="2"&gt;global (not timed)&lt;/th&gt;
  &lt;th colspan="2"&gt;thread (not timed)&lt;/th&gt;
  &lt;th colspan="2"&gt;thread (all cycles)&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Connections&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;757&lt;/td&gt; &lt;td&gt;6.20&lt;/td&gt;
  &lt;td&gt;752&lt;/td&gt; &lt;td&gt;6.82&lt;/td&gt;
  &lt;td&gt;739&lt;/td&gt; &lt;td&gt;8.43&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1362&lt;/td&gt; &lt;td&gt;5.35&lt;/td&gt;
  &lt;td&gt;1327&lt;/td&gt; &lt;td&gt;7.78&lt;/td&gt;
  &lt;td&gt;1293&lt;/td&gt; &lt;td&gt;10.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;4&lt;/td&gt;
  &lt;td&gt;2441&lt;/td&gt; &lt;td&gt;6.48&lt;/td&gt;
  &lt;td&gt;2385&lt;/td&gt; &lt;td&gt;8.62&lt;/td&gt;
  &lt;td&gt;2328&lt;/td&gt; &lt;td&gt;10.80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;8&lt;/td&gt;
  &lt;td&gt;4490&lt;/td&gt; &lt;td&gt;11.72&lt;/td&gt;
  &lt;td&gt;4384&lt;/td&gt; &lt;td&gt;13.80&lt;/td&gt;
  &lt;td&gt;4165&lt;/td&gt; &lt;td&gt;18.11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;12&lt;/td&gt;
  &lt;td&gt;4489&lt;/td&gt; &lt;td&gt;10.88&lt;/td&gt;
  &lt;td&gt;4411&lt;/td&gt; &lt;td&gt;12.43&lt;/td&gt;
  &lt;td&gt;4220&lt;/td&gt; &lt;td&gt;16.22&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;16&lt;/td&gt;
  &lt;td&gt;4489&lt;/td&gt; &lt;td&gt;10.90&lt;/td&gt;
  &lt;td&gt;4436&lt;/td&gt; &lt;td&gt;11.95&lt;/td&gt;
  &lt;td&gt;4284&lt;/td&gt; &lt;td&gt;14.97&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;32&lt;/td&gt;
  &lt;td&gt;4336&lt;/td&gt; &lt;td&gt;10.67&lt;/td&gt;
  &lt;td&gt;4232&lt;/td&gt; &lt;td&gt;12.81&lt;/td&gt;
  &lt;td&gt;3992&lt;/td&gt; &lt;td&gt;17.76&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;48&lt;/td&gt;
  &lt;td&gt;4244&lt;/td&gt; &lt;td&gt;10.88&lt;/td&gt;
  &lt;td&gt;4111&lt;/td&gt; &lt;td&gt;13.67&lt;/td&gt;
  &lt;td&gt;3876&lt;/td&gt; &lt;td&gt;18.61&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;64 (*)&lt;/td&gt;
  &lt;td&gt;3977&lt;/td&gt; &lt;td&gt;3.42&lt;/td&gt;
  &lt;td&gt;3040&lt;/td&gt; &lt;td&gt;26.18&lt;/td&gt;
  &lt;td&gt;2527&lt;/td&gt; &lt;td&gt;38.64&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;128 (*)&lt;/td&gt;
  &lt;td&gt;2830&lt;/td&gt; &lt;td&gt;20.01&lt;/td&gt;
  &lt;td&gt;1972&lt;/td&gt; &lt;td&gt;44.26&lt;/td&gt;
  &lt;td&gt;1897&lt;/td&gt; &lt;td&gt;46.38&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;256 (*)&lt;/td&gt;
  &lt;td&gt;1683&lt;/td&gt; &lt;td&gt;3.61&lt;/td&gt;
  &lt;td&gt;1671&lt;/td&gt; &lt;td&gt;4.30&lt;/td&gt;
  &lt;td&gt;1629&lt;/td&gt; &lt;td&gt;6.70&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
(*) Noise at 64/128/256 still makes results unstable.&lt;br /&gt;
These new results, using a different configuration but still the same code in mysql-trunk, are interesting for two reasons.&lt;br /&gt;
First, it confirms the effect of timing alone. Timing a &lt;b&gt;lot&lt;/b&gt; or events takes time, and timing a lot of events with a &lt;b&gt;bad timer&lt;/b&gt; makes things really worse. Using the CYCLE timer for waits, stages and statements here, in the "thread (all cycle)" configuration, helped to regain 5 percent.&lt;br /&gt;
Second, it shows that once all timers are removed from the code path, the overhead is still in the ~11% range for the global only consumer. The code probably has room for optimizations, see the next section.&lt;br /&gt;
&lt;h1&gt;

The tuning benchmark&lt;/h1&gt;
The current code in mysql-trunk (at time of writing) can be improved and optimized, in an effort to reduce the overhead even more. A long list of different tweaks, changes, fixes ... has been the topic of a lot of research and tuning lately. Instead of going through each change, the cumulated changes are available in a different branch, in mysql-trunk-pfs-tuning.&lt;br /&gt;
This branch is &lt;a href="https://code.launchpad.net/%7Emarc-alff/mysql-server/mysql-trunk-pfs-tuning"&gt;available&lt;/a&gt; on launchpad for the technically curious. A bit of warning: it is used only for prototyping and benchmarking to see what code does (or does not) work better. It may not even build for your platform. Do not use this in production.&lt;br /&gt;
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;mysql-trunk-pfs-tuning&lt;/th&gt;
  &lt;th colspan="2"&gt;without pfs (baseline)&lt;/th&gt;
  &lt;th colspan="2"&gt;disabled&lt;/th&gt;
  &lt;th colspan="2"&gt;off&lt;/th&gt;
  &lt;th colspan="2"&gt;global (not timed)&lt;/th&gt;
  &lt;th colspan="2"&gt;global (timed)&lt;/th&gt;
  &lt;th colspan="2"&gt;thread (not timed)&lt;/th&gt;
  &lt;th colspan="2"&gt;thread (timed)&lt;/th&gt;
  &lt;th colspan="2"&gt;thread (all cycles)&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Connections&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
  &lt;th&gt;TPS&lt;/th&gt; &lt;th&gt;Overhead (%)&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;819&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;788&lt;/td&gt; &lt;td&gt;3.79&lt;/td&gt;
  &lt;td&gt;778&lt;/td&gt; &lt;td&gt;5.01&lt;/td&gt;
  &lt;td&gt;771&lt;/td&gt; &lt;td&gt;5.86&lt;/td&gt;
  &lt;td&gt;684&lt;/td&gt; &lt;td&gt;16.48&lt;/td&gt;
  &lt;td&gt;755&lt;/td&gt; &lt;td&gt;7.81&lt;/td&gt;
  &lt;td&gt;678&lt;/td&gt; &lt;td&gt;17.22&lt;/td&gt;
  &lt;td&gt;744&lt;/td&gt; &lt;td&gt;9.16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1431&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;1405&lt;/td&gt; &lt;td&gt;1.82&lt;/td&gt;
  &lt;td&gt;1383&lt;/td&gt; &lt;td&gt;3.35&lt;/td&gt;
  &lt;td&gt;1354&lt;/td&gt; &lt;td&gt;5.38&lt;/td&gt;
  &lt;td&gt;1212&lt;/td&gt; &lt;td&gt;15.30&lt;/td&gt;
  &lt;td&gt;1329&lt;/td&gt; &lt;td&gt;7.13&lt;/td&gt;
  &lt;td&gt;1199&lt;/td&gt; &lt;td&gt;16.21&lt;/td&gt;
  &lt;td&gt;1307&lt;/td&gt; &lt;td&gt;8.67&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;4&lt;/td&gt;
  &lt;td&gt;2598&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;2567&lt;/td&gt; &lt;td&gt;1.19&lt;/td&gt;
  &lt;td&gt;2522&lt;/td&gt; &lt;td&gt;2.93&lt;/td&gt;
  &lt;td&gt;2452&lt;/td&gt; &lt;td&gt;5.62&lt;/td&gt;
  &lt;td&gt;2163&lt;/td&gt; &lt;td&gt;16.74&lt;/td&gt;
  &lt;td&gt;2394&lt;/td&gt; &lt;td&gt;7.85&lt;/td&gt;
  &lt;td&gt;2141&lt;/td&gt; &lt;td&gt;17.59&lt;/td&gt;
  &lt;td&gt;2371&lt;/td&gt; &lt;td&gt;8.74&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;8&lt;/td&gt;
  &lt;td&gt;4949&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;4980&lt;/td&gt; &lt;td&gt;-0.63&lt;/td&gt;
  &lt;td&gt;4799&lt;/td&gt; &lt;td&gt;3.03&lt;/td&gt;
  &lt;td&gt;4635&lt;/td&gt; &lt;td&gt;6.34&lt;/td&gt;
  &lt;td&gt;4105&lt;/td&gt; &lt;td&gt;17.05&lt;/td&gt;
  &lt;td&gt;4445&lt;/td&gt; &lt;td&gt;10.18&lt;/td&gt;
  &lt;td&gt;4061&lt;/td&gt; &lt;td&gt;17.94&lt;/td&gt;
  &lt;td&gt;4367&lt;/td&gt; &lt;td&gt;11.76&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;12&lt;/td&gt;
  &lt;td&gt;4948&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;4936&lt;/td&gt; &lt;td&gt;0.24&lt;/td&gt;
  &lt;td&gt;4759&lt;/td&gt; &lt;td&gt;3.82&lt;/td&gt;
  &lt;td&gt;4616&lt;/td&gt; &lt;td&gt;6.71&lt;/td&gt;
  &lt;td&gt;4112&lt;/td&gt; &lt;td&gt;16.90&lt;/td&gt;
  &lt;td&gt;4478&lt;/td&gt; &lt;td&gt;9.50&lt;/td&gt;
  &lt;td&gt;4076&lt;/td&gt; &lt;td&gt;17.62&lt;/td&gt;
  &lt;td&gt;4390&lt;/td&gt; &lt;td&gt;11.28&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;16&lt;/td&gt;
  &lt;td&gt;4944&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;4931&lt;/td&gt; &lt;td&gt;0.26&lt;/td&gt;
  &lt;td&gt;4754&lt;/td&gt; &lt;td&gt;3.84&lt;/td&gt;
  &lt;td&gt;4601&lt;/td&gt; &lt;td&gt;6.94&lt;/td&gt;
  &lt;td&gt;4131&lt;/td&gt; &lt;td&gt;16.44&lt;/td&gt;
  &lt;td&gt;4476&lt;/td&gt; &lt;td&gt;9.53&lt;/td&gt;
  &lt;td&gt;4077&lt;/td&gt; &lt;td&gt;17.54&lt;/td&gt;
  &lt;td&gt;4384&lt;/td&gt; &lt;td&gt;11.33&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;32&lt;/td&gt;
  &lt;td&gt;4764&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;4753&lt;/td&gt; &lt;td&gt;0.23&lt;/td&gt;
  &lt;td&gt;4596&lt;/td&gt; &lt;td&gt;3.53&lt;/td&gt;
  &lt;td&gt;4455&lt;/td&gt; &lt;td&gt;6.49&lt;/td&gt;
  &lt;td&gt;3984&lt;/td&gt; &lt;td&gt;16.37&lt;/td&gt;
  &lt;td&gt;4286&lt;/td&gt; &lt;td&gt;10.03&lt;/td&gt;
  &lt;td&gt;3945&lt;/td&gt; &lt;td&gt;17.19&lt;/td&gt;
  &lt;td&gt;4200&lt;/td&gt; &lt;td&gt;11.84&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;48&lt;/td&gt;
  &lt;td&gt;4682&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;4681&lt;/td&gt; &lt;td&gt;0.02&lt;/td&gt;
  &lt;td&gt;4519&lt;/td&gt; &lt;td&gt;3.48&lt;/td&gt;
  &lt;td&gt;4377&lt;/td&gt; &lt;td&gt;6.51&lt;/td&gt;
  &lt;td&gt;3908&lt;/td&gt; &lt;td&gt;16.53&lt;/td&gt;
  &lt;td&gt;4202&lt;/td&gt; &lt;td&gt;10.25&lt;/td&gt;
  &lt;td&gt;3860&lt;/td&gt; &lt;td&gt;17.56&lt;/td&gt;
  &lt;td&gt;4111&lt;/td&gt; &lt;td&gt;12.20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;64 (*)&lt;/td&gt;
  &lt;td&gt;4148&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;3881&lt;/td&gt; &lt;td&gt;6.44&lt;/td&gt;
  &lt;td&gt;2583&lt;/td&gt; &lt;td&gt;37.73&lt;/td&gt;
  &lt;td&gt;3653&lt;/td&gt; &lt;td&gt;11.93&lt;/td&gt;
  &lt;td&gt;2916&lt;/td&gt; &lt;td&gt;29.70&lt;/td&gt;
  &lt;td&gt;3082&lt;/td&gt; &lt;td&gt;25.70&lt;/td&gt;
  &lt;td&gt;2863&lt;/td&gt; &lt;td&gt;30.98&lt;/td&gt;
  &lt;td&gt;3496&lt;/td&gt; &lt;td&gt;15.72&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;128 (*)&lt;/td&gt;
  &lt;td&gt;3659&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;2034&lt;/td&gt; &lt;td&gt;44.41&lt;/td&gt;
  &lt;td&gt;2024&lt;/td&gt; &lt;td&gt;44.68&lt;/td&gt;
  &lt;td&gt;1983&lt;/td&gt; &lt;td&gt;45.80&lt;/td&gt;
  &lt;td&gt;1924&lt;/td&gt; &lt;td&gt;47.42&lt;/td&gt;
  &lt;td&gt;2011&lt;/td&gt; &lt;td&gt;45.04&lt;/td&gt;
  &lt;td&gt;1886&lt;/td&gt; &lt;td&gt;48.46&lt;/td&gt;
  &lt;td&gt;1939&lt;/td&gt; &lt;td&gt;47.01&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;256 (*)&lt;/td&gt;
  &lt;td&gt;2514&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;
  &lt;td&gt;1746&lt;/td&gt; &lt;td&gt;30.55&lt;/td&gt;
  &lt;td&gt;1732&lt;/td&gt; &lt;td&gt;31.11&lt;/td&gt;
  &lt;td&gt;1690&lt;/td&gt; &lt;td&gt;32.78&lt;/td&gt;
  &lt;td&gt;1632&lt;/td&gt; &lt;td&gt;35.08&lt;/td&gt;
  &lt;td&gt;1724&lt;/td&gt; &lt;td&gt;31.42&lt;/td&gt;
  &lt;td&gt;1640&lt;/td&gt; &lt;td&gt;34.77&lt;/td&gt;
  &lt;td&gt;1646&lt;/td&gt; &lt;td&gt;34.53&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
We can see some progress:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;When all consumers are off, the overhead is in the 3% to 4% range, which is much better compared to ~8%.&lt;/li&gt;
&lt;li&gt;The "global (timed)" and "thread (timed)" configurations still have an important overhead because they use the nanosecond timer, but this overhead decreased, which shows the benefits of the code optimizations.&lt;/li&gt;
&lt;li&gt;The "thread (all cycles)" overhead is in the ~11% range.&lt;/li&gt;
&lt;/ul&gt;
Now that's better. With every instruments enabled and timed, for all waits stages and statements, and with statistics collected globally and per thread, 11% for this wealth of information is not so bad. Especially knowing that the overhead can be changed back to 3-4% at anytime, since all this configuration can be changed dynamically.&lt;br /&gt;
&lt;h1&gt;

Take aways&lt;/h1&gt;
The most important facts found here:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Timer performances do vary between platforms, and have a great impact. Check the timer performance itself with table performance_schema.performance_timers before deciding to time events.&lt;/li&gt;
&lt;li&gt;The performance schema code itselt can be improved. Current optimizations are available in mysql-trunk-pfs-tuning, as a preview.&lt;/li&gt;
&lt;li&gt;Overall, the performance schema captures instrumentation events at a very high rate. Limiting the choice of consumers and instruments to use is a good way to cut down the overhead.&lt;/li&gt;
&lt;li&gt;There is no magic formula that says "overhead is X". Overhead depends so much on the work load, the hardware, the configuration, etc, that the best answer is "it depends".&lt;/li&gt;
&lt;/ul&gt;
The real question about overhead, given that it depends so much, really boils down to "What is the overhead for my application ?". The best way to find that is to try it ...&lt;br /&gt;
-- Marc Alff</description><link>http://marcalff.blogspot.com/2011/06/performance-schema-overhead-tuning.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>4</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-8039612588307819750</guid><pubDate>Wed, 20 Apr 2011 05:58:00 +0000</pubDate><atom:updated>2011-04-20T16:42:44.615+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>Performance schema faq #2, what are all these server startup options ?</title><description>&lt;p&gt;One of the first thing to do to use the performance schema is to add "performance_schema" in the my.cnf file.&lt;/p&gt;
&lt;p&gt;This typically prompts a long list of question from users, as there is a lot to know here.&lt;/p&gt;
&lt;p&gt;This article attempts to cover more specifically this area.&lt;/p&gt;
&lt;p&gt;It is long, but (I hope) also worth it, so keep reading ;)&lt;/p&gt;
&lt;p&gt;Also, since some new performance schema features have been advertised in the mysql labs, this article also covers some never seen before parts of the performance schema.&lt;/p&gt;
&lt;p&gt;Really, keep reading ;)&lt;/p&gt;
&lt;h2&gt;Q: Why do I even have to do anything ? Can the performance schema not be enabled by default ?&lt;/h2&gt;
&lt;p&gt;No. It could, but this is not a good choice.&lt;/p&gt;
&lt;p&gt;Let's face it, some users do not even read the documentation.&lt;/p&gt;
&lt;p&gt;If someone is not even aware that the performance schema feature exists in 5.5 (or 5.6), turning it on by default for a new 5.5 installation, or even worse, turning it on by default after a 5.1 to 5.5 upgrade is not going to do anyone any good.&lt;/p&gt;
&lt;p&gt;The performance schema will collect data, eat memory, spend time computing all kinds of aggregates that can be viewed from nice tables in the new performance_schema database ... that nobody will ever select from.&lt;/p&gt;
&lt;p&gt;The performance schema is a new feature, and it is also an optional feature.&lt;/p&gt;
&lt;p&gt;Forcing to use it by default would only irritate people doing a migration to a new release, which is never the best time to try new features, no matter how good they are.
When doing a migration, the concern is typically to be back in production as soon as possible, and anything that can be sorted out later should be done ... later.&lt;/p&gt;
&lt;p&gt;So, the long answer is that, by default, the performance schema is disabled. This is a conscious, conservative, choice.&lt;/p&gt;
&lt;h2&gt;Q: Ok, so I need to turn P_S on. Now, why are there so many other parameters ?&lt;/h2&gt;
&lt;p&gt;By the way, "P_S" is the acronym that is used internally for the performance schema, which mirrors "I_S" for the information_schema. This is not to be confused with "PS", which stands for prepared statements.&lt;/p&gt;
&lt;p&gt;So yes, the performance schema has in fact many different startup parameters, which can also be seen as server variables.&lt;/p&gt;
&lt;p&gt;Looking at mysql-5.6-labs-performance-schema for example:&lt;/p&gt;

&lt;pre&gt;
mysql&gt; show variables like "performance_schema%";
+--------------------------------------------------------+-------+
| Variable_name                                          | Value |
+--------------------------------------------------------+-------+
| performance_schema                                     | ON    |
| performance_schema_events_stages_history_long_size     | 1000  |
| performance_schema_events_stages_history_size          | 10    |
| performance_schema_events_statements_history_long_size | 1000  |
| performance_schema_events_statements_history_size      | 10    |
| performance_schema_events_waits_history_long_size      | 10000 |
| performance_schema_events_waits_history_size           | 10    |
| performance_schema_max_cond_classes                    | 80    |
| performance_schema_max_cond_instances                  | 1000  |
| performance_schema_max_file_classes                    | 50    |
| performance_schema_max_file_handles                    | 32768 |
| performance_schema_max_file_instances                  | 10000 |
| performance_schema_max_hosts                           | 100   |
| performance_schema_max_mutex_classes                   | 200   |
| performance_schema_max_mutex_instances                 | 5000  |
| performance_schema_max_rwlock_classes                  | 30    |
| performance_schema_max_rwlock_instances                | 5000  |
| performance_schema_max_stage_classes                   | 100   |
| performance_schema_max_statement_classes               | 165   |
| performance_schema_max_table_handles                   | 1000  |
| performance_schema_max_table_instances                 | 500   |
| performance_schema_max_thread_classes                  | 50    |
| performance_schema_max_thread_instances                | 200   |
| performance_schema_max_user_hosts                      | 100   |
| performance_schema_max_users                           | 100   |
| performance_schema_setup_actors_size                   | 100   |
| performance_schema_setup_objects_size                  | 100   |
+--------------------------------------------------------+-------+
27 rows in set (0.00 sec)
&lt;/pre&gt;

&lt;p&gt;The reason why these parameters even exist is the result of significant architectural choices, which in turn are driven by very hard constraints on the system, so let's look at some details here ...&lt;/p&gt;

&lt;h2&gt;Problem: Monitoring a server should not freeze the server.&lt;/h2&gt;

&lt;p&gt;In other words, executing select * from performance_schema.&lt;your favorite table&gt; should not cause other sessions to stop working.&lt;/p&gt;
&lt;p&gt;That includes precisely the application connection that is currently executing instrumented code, which in turn feeds the very performance_schema table being read.&lt;/p&gt;

&lt;p&gt;This has nothing to do with how the data is exposed, this would be the same for a performance_schema table, an information_schema table, a SHOW &lt;insert your favorite here&gt; command.&lt;/p&gt;

&lt;p&gt;This has to do with how the statistics are represented internally.&lt;/p&gt;

&lt;p&gt;A way to implement instrumentation that is known to cause problems is for example the implementation of the SHOW PROCESSLIST statement.&lt;/p&gt;

&lt;p&gt;A monitoring application that execute SHOW PROCESSLIST will partially freeze the server, preventing new sessions to connect, or old sessions to disconnect.
This is because SHOW PROCESSLIST will lock a critical server mutex, LOCK_thread_count,
for the time it takes to loop through all the threads.&lt;/p&gt;

&lt;p&gt;See &lt;a href="http://bugs.mysql.com/bug.php?id=42930"&gt;Bug#42930&lt;/a&gt;, for an example of similar problems.&lt;/p&gt;

&lt;h2&gt;Solution: the performance schema is lock-less&lt;/h2&gt;

&lt;p&gt;One of the goal of the performance schema implementation is to never be in that situation. To avoid that the monitoring application causes other threads to choke, the best way is to have *no* lock shared between the monitoring connection and the instrumented code.&lt;/p&gt;

&lt;p&gt;No matter how it's done, the performance schema instrumentation should not use locks.&lt;/p&gt;

&lt;h2&gt;Problem: Monitoring a server should not crash the server&lt;/h2&gt;

&lt;p&gt;Ok, so let's pretend the SHOW PROCESSLIST implementation used as example here is not locking LOCK_thread_count at all. Developers to not add mutex locks in the code just for pleasure, they add locks to enforce data integrity and prevent bad things to happen.&lt;/p&gt;

&lt;p&gt;The data protected by the lock is a linked list of all the connected sessions, where each session is represented by a THD object. The list is global to the server, and each THD is allocated and freed when users connect / disconnect from the server.&lt;/p&gt;

&lt;p&gt;Without the lock, very soon, the execution (or this now hypothetical) SHOW PROCESSLIST statement would crash when using a bogus THD record, typically when looking at freed (and worse already reused) memory for a thread that just disconnected.&lt;/p&gt;

&lt;p&gt;What this points to is that, when using code that is lock-free, using memory that is dynamically allocated and freed by other threads is going to be a real challenge, since there are no more protections in place.&lt;/p&gt;

&lt;h2&gt;Solution: the performance schema is not using dynamic memory&lt;/h2&gt;

&lt;p&gt;Since using malloc / free cause problem, then ... the performance schema code does not use malloc and free.&lt;/p&gt;

&lt;p&gt;Instead, memory is allocated once and for all at server startup, and is freed when the server shuts down. During normal operations (everything in between), the performance schema memory is considered "static".&lt;/p&gt;

&lt;p&gt;This has actually significant benefits, since a pointer to a region of this "performance schema static memory" is always guaranteed to point to valid memory.&lt;/p&gt;

&lt;p&gt;Since using a linked list also causes problems, then ... the performance schema code prefers to use arrays.&lt;/p&gt;

&lt;p&gt;The net result is that all the performance schema memory used to keep track of statistics in fact consist of arrays, allocated once.&lt;/p&gt;

&lt;p&gt;Different arrays are used for different things. The size of these various arrays is given by the various server startup parameters.&lt;/p&gt;

&lt;p&gt;Still looking at the SHOW PROCESSLIST statement, the performance schema instrumentation is in fact exposing a table named performance_schema.threads.&lt;/p&gt;

&lt;p&gt;The data for the threads table is stored in an array, and the size of this array is given by the parameter performance_schema_max_thread_instances.&lt;/p&gt;

&lt;p&gt;The benefit: select * from performance_schema.threads is lock-less. The inconvenience: performance_schema_max_thread_instances must come from somewhere.&lt;/p&gt;

&lt;h2&gt;Q: Ok, so there are sizing parameters. But so many of them ?&lt;/h2&gt;

&lt;p&gt;Every new instrumentation (mutex, file io, table lock, statements, ...) instruments different parts of the code, and needs different types of performance schema buffers.
This is actually a good property, because this allows to control each type of instrumentation -- and how much memory to use for it -- independently.&lt;/p&gt;

&lt;p&gt;So, each time a new buffer is used, how to size it is exposed as a parameter.&lt;/p&gt;

&lt;h2&gt;Q: How about default values that work out of the box ?&lt;/h2&gt;

&lt;p&gt;Given the wide range of deployments where the MySQL server can be installed, from a laptop that will ever see 2 clients and 10 tables for a demo,
to a production scale server that can support a very large web farm and data model, whatever "default value" is written in the code will never satisfy everybody.&lt;/p&gt;
&lt;p&gt;That is a given, there is no way around it.&lt;/p&gt;

&lt;p&gt;If the default values are too big, starting a server on a small machine will consume too much memory, giving the impression that the performance schema is a "monster" and can not be used, say, in development when testing an application.&lt;/p&gt;

&lt;p&gt;If the default values are too small, the performance schema will miss events at runtime, and will not be able to collect data for everything, giving the impression that it is broken and does not work.&lt;/p&gt;

&lt;p&gt;The default values that are currently in the code should be reasonable enough so that running a server with the performance schema gives meaningful results, so that people can get a first impression of what the performance schema can do, out of the box, by changing just *one* parameter (to enable the performance schema).&lt;/p&gt;

&lt;p&gt;Past that, when deploying the performance schema in a real production environment, or to do serious benchmarks, taking a closer look at the configuration itself will unfortunately be a necessary step at some point.&lt;/p&gt;

&lt;p&gt;That being said, the picture is actually not so complex, since not so many parameters really need to be changed.&lt;/p&gt;

&lt;h2&gt;Q: What are the parameters I can just forget about ?&lt;/h2&gt;

&lt;pre&gt;
mysql&gt; show variables like "performance_schema_%_classes";
+------------------------------------------+-------+
| Variable_name                            | Value |
+------------------------------------------+-------+
| performance_schema_max_cond_classes      | 80    |
| performance_schema_max_file_classes      | 50    |
| performance_schema_max_mutex_classes     | 200   |
| performance_schema_max_rwlock_classes    | 30    |
| performance_schema_max_stage_classes     | 100   |
| performance_schema_max_statement_classes | 165   |
| performance_schema_max_thread_classes    | 50    |
+------------------------------------------+-------+
7 rows in set (0.00 sec)
&lt;/pre&gt;

&lt;p&gt;All these parameters follow the same principle, so let's take for example performance_schema_max_mutex_classes. What this value of 200 means, is that there is room by default for 200 different mutex instrumentation.&lt;/p&gt;

&lt;p&gt;The number of mutex instrumentation varies as more and more code is instrumented, which varies by releases, and the way to find out what is currently instrumented is just to look at the setup_instruments table.&lt;/p&gt;

&lt;pre&gt;
mysql&gt; select count(*) from performance_schema.setup_instruments where name like "wait/synch/mutex/%";
+----------+
| count(*) |
+----------+
|      125 |
+----------+
1 row in set (0.00 sec)
&lt;/pre&gt;

&lt;p&gt;125 of the 200 mutex classes slots are used, so there is still room left: everything is fine here.&lt;/p&gt;

&lt;p&gt;There is a catch here, as both the 125 and the 200 comes from code shipped with the server ... so, if one value exceeds the other, it will be adjusted anyway.&lt;/p&gt;

&lt;p&gt;The only reason this parameter is even exposed in the first place, is that, if a third party plugin also contains some performance schema instrumentation for mutex classes (and in this case, for a lot of them, since there are still 75 slots left),
loading this third party plugin in the server will cause starvation, so the max_mutex_class setting will need to be adjusted.&lt;/p&gt;
&lt;p&gt;And no, we can not predict how many mutexes a third party will use.&lt;/p&gt;

&lt;p&gt;In practice, this settings can safely be forgotten. The day it will be needed, it will be there, and people might appreciate then the fact that not everything is hard coded.&lt;/p&gt;

&lt;h2&gt;Q: What are the parameters that are not really sensitive, where the value has little effect on performance and/or functionality ?&lt;/h2&gt;

&lt;pre&gt;
mysql&gt; show variables like "performance_schema_%_history%_size";
+--------------------------------------------------------+-------+
| Variable_name                                          | Value |
+--------------------------------------------------------+-------+
| performance_schema_events_stages_history_long_size     | 1000  |
| performance_schema_events_stages_history_size          | 10    |
| performance_schema_events_statements_history_long_size | 1000  |
| performance_schema_events_statements_history_size      | 10    |
| performance_schema_events_waits_history_long_size      | 10000 |
| performance_schema_events_waits_history_size           | 10    |
+--------------------------------------------------------+-------+
6 rows in set (0.01 sec)
&lt;/pre&gt;

&lt;p&gt;These settings affect how many records are kept in the various history buffers,
so they have a direct impact on the amount of memory used. The time is takes to write a new record in history (and drop the oldest one) is fixed, and does not depends on the history size, to this sizing parameters do not impact runtime performances.&lt;/p&gt;

&lt;pre&gt;
mysql&gt; show variables like "performance_schema_setup_%_size";
+---------------------------------------+-------+
| Variable_name                         | Value |
+---------------------------------------+-------+
| performance_schema_setup_actors_size  | 100   |
| performance_schema_setup_objects_size | 100   |
+---------------------------------------+-------+
2 rows in set (0.00 sec)
&lt;/pre&gt;

&lt;p&gt;This directly control the size of corresponding tables setup_actor and setup_object.
How many entries are in these tables is directly up to the DBA. The performance schema uses a hash index internally, plus some level of cache on top, so that the number of records in these tables has no effect at all on performances.&lt;/p&gt;

&lt;pre&gt;
mysql&gt; show variables like "performance_schema_max_user%";
+-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| performance_schema_max_user_hosts | 100   |
| performance_schema_max_users      | 100   |
+-----------------------------------+-------+
2 rows in set (0.01 sec)

mysql&gt; show variables like "performance_schema_max_host%";
+------------------------------+-------+
| Variable_name                | Value |
+------------------------------+-------+
| performance_schema_max_hosts | 100   |
+------------------------------+-------+
1 row in set (0.00 sec)
&lt;/pre&gt;

&lt;p&gt;For the performance_schema.users, performance_schema.hosts, and performance_schema.user_hosts tables, the performance schema also uses a hash index by user name and/or host name, so the total size of these tables is not going to significantly impact the time to look up a given record, which is done once when a session connects to the server.&lt;/p&gt;

&lt;p&gt;Sizing these tables according to how many different users and or machines are connecting to the database server, however, will have a direct impact on whether or not the performance schema can keep statistics for everybody.&lt;/p&gt;

&lt;h2&gt;Q: What are the parameters I should really pay attention to then ?&lt;/h2&gt;

&lt;pre&gt;
mysql&gt; show variables like "performance_schema_%_instances";
+-----------------------------------------+-------+
| Variable_name                           | Value |
+-----------------------------------------+-------+
| performance_schema_max_cond_instances   | 1000  |
| performance_schema_max_file_instances   | 10000 |
| performance_schema_max_mutex_instances  | 5000  |
| performance_schema_max_rwlock_instances | 5000  |
| performance_schema_max_table_instances  | 500   |
| performance_schema_max_thread_instances | 200   |
+-----------------------------------------+-------+
6 rows in set (0.01 sec)

mysql&gt; show variables like "performance_schema_%_handles";
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| performance_schema_max_file_handles  | 32768 |
| performance_schema_max_table_handles | 1000  |
+--------------------------------------+-------+
2 rows in set (0.00 sec)
&lt;/pre&gt;

&lt;p&gt;The most critical parameters that affect how the performance schema is performing are the parameters that control the different buffers used to instrument what the code is doing, and the lower level it gets, the more sensitive it gets.&lt;/p&gt;

&lt;p&gt;First, to make things clear, the values you see pasted in this blog are nowhere near realistic values. They are the values used by the mysql-test-run test scripts, which are chosen to be very low just to put more stress on the performance schema code itself. The goal of the test suite is to torture the performance schema, not to make it fly.&lt;/p&gt;

&lt;p&gt;All these different parameters follow the same principle, so let's take an example again, with performance_schema_max_thread_instances.&lt;/p&gt;

&lt;p&gt;A value of N means that the performance schema will ever be able to keep track of N threads at a time. In practice however, performance will degrade badly when reaching the very last -- and rare -- open slots in an array of size N, when trying to allocate a new entry for the very last thread that connects.&lt;/p&gt;

&lt;p&gt;Finding an empty slot in an array 50 percent full is easier than finding an empty slot in an array 60, 70, 80 ... 95 ? 99 ? percent full.&lt;/p&gt;

&lt;p&gt;The more memory is given to the performance schema for a given buffer, the lower the density of allocated records will be in that buffer, making performances (when allocating a new entry) better. Once an entry is allocated, all the performance schema code directly use the record with a direct pointer, so there is nothing else to tune.&lt;/p&gt;

&lt;p&gt;Sizing this parameter to the "proper" value depends on two things a) the (estimated) maximum number of instrumented objects the server will ever see at a given time, and b) the load factor to apply to this buffer.&lt;/p&gt;

&lt;p&gt;Estimating the former really depends on the nature of each buffer.&lt;/p&gt;

&lt;p&gt;For threads for example, the total number of threads is going to be driven by the --max-connection parameter, plus a few extra threads used internally. There might be a few threads for replication, the event scheduler, storage engines, etc, but not that many, so for example "max-connection + 50" seems very generous already.&lt;/p&gt;

&lt;p&gt;Estimating the later (the load factor) really depends on the volatility of each buffer.&lt;/p&gt;

&lt;p&gt;For buffers where records are rarely added, like for example the performance_schema.host table (a record is inserted only when a connection from a never before seen machine is found), the record density of the table is not going to have a huge impact on performances.&lt;/p&gt;

&lt;p&gt;For buffers where records are allocated and freed all the time, finding a free record the first time beats looping forever to find one, so a very low density is key.&lt;/p&gt;

&lt;p&gt;An example of a high volatility buffer is performance_schema_max_table_handles, as table handles are allocated each time a table is opened, which, in a database server, happens very often.&lt;/p&gt;

&lt;h2&gt;Q: Humm. What happens when a buffer is too small ?&lt;/h2&gt;

&lt;p&gt;That part is actually very simple: the performance schema will tell you.&lt;/p&gt;

&lt;pre&gt;
mysql&gt; show status like "performance_schema%";
+-------------------------------------------+-------+
| Variable_name                             | Value |
+-------------------------------------------+-------+
| Performance_schema_cond_classes_lost      | 0     |
| Performance_schema_cond_instances_lost    | 0     |
| Performance_schema_file_classes_lost      | 0     |
| Performance_schema_file_handles_lost      | 0     |
| Performance_schema_file_instances_lost    | 0     |
| Performance_schema_hosts_lost             | 0     |
| Performance_schema_locker_lost            | 0     |
| Performance_schema_mutex_classes_lost     | 0     |
| Performance_schema_mutex_instances_lost   | 0     |
| Performance_schema_rwlock_classes_lost    | 0     |
| Performance_schema_rwlock_instances_lost  | 0     |
| Performance_schema_stage_classes_lost     | 0     |
| Performance_schema_statement_classes_lost | 0     |
| Performance_schema_table_handles_lost     | 0     |
| Performance_schema_table_instances_lost   | 0     |
| Performance_schema_thread_classes_lost    | 0     |
| Performance_schema_thread_instances_lost  | 0     |
| Performance_schema_user_hosts_lost        | 0     |
| Performance_schema_users_lost             | 0     |
+-------------------------------------------+-------+
19 rows in set (0.00 sec)
&lt;/pre&gt;

&lt;h2&gt;Q: Ok. And what happens when a buffer is too big ?&lt;/h2&gt;

&lt;p&gt;Nothing really.&lt;/p&gt;
&lt;p&gt;The performance schema will use memory depending on the sizing used,
so big sizing means a lot of memory, but that's all.&lt;/p&gt;

&lt;p&gt;To find how much memory is used, and in particular how each setting affects each buffer size, there is SHOW ENGINE PERFORMANCE_SCHEMA STATUS.&lt;/p&gt;

&lt;pre&gt;
mysql&gt; SHOW ENGINE PERFORMANCE_SCHEMA STATUS;
+--------------------+----------------------------------------------------------------+----------+
| Type               | Name                                                           | Status   |
+--------------------+----------------------------------------------------------------+----------+
| performance_schema | events_waits_current.row_size                                  | 168      |
| performance_schema | events_waits_current.row_count                                 | 800      |
| performance_schema | events_waits_history.row_size                                  | 168      |
| performance_schema | events_waits_history.row_count                                 | 2000     |
| performance_schema | events_waits_history.memory                                    | 336000   |
...
| performance_schema | events_statements_current.row_size                             | 1976     |
| performance_schema | events_statements_current.row_count                            | 200      |
| performance_schema | events_statements_current.memory                               | 395200   |
| performance_schema | performance_schema.memory                                      | 58928908 |
+--------------------+----------------------------------------------------------------+----------+
129 rows in set (0.00 sec)
&lt;/pre&gt;

&lt;h2&gt;Q: Can the sizing part be automated somehow ?&lt;/h2&gt;

&lt;p&gt;It is not automated yet, but it sure can be, to some extent.&lt;/p&gt;

&lt;p&gt;What is needed to get that done is first, to identify the magic formula that says, for each instrumentation type, something like:&lt;/p&gt;

&lt;p&gt;total number of mutex = (number of singleton) + (number of tables * mutexes by table) + (number of threads * mutexes by thread) + ...&lt;/p&gt;

&lt;p&gt;The challenge here is that this magic formula changes all the time, as implementation changes, but overall, there are not that many parameters in it. In any case, that part can be resolved with at least good enough heuristics.&lt;/p&gt;

&lt;p&gt;Some parts of the magic formula also comes from the application that sends queries to the server. All things being equal, a statement that joins 20 tables is going to consume more table handles compared to a statement that just uses 1 or 2 tables, so the way the application is written also has an effect.&lt;/p&gt;

&lt;p&gt;The second part is some feedback from users, and some benchmarking, to find reasonable values for load factors, based on each instrument type.&lt;/p&gt;

&lt;p&gt;This is a long post already, thanks for reading it.&lt;/p&gt;

&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;-- Marc Alff, Oracle&lt;/p&gt;</description><link>http://marcalff.blogspot.com/2011/04/performance-schema-faq-2-what-are-all.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>4</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-7834263837591866161</guid><pubDate>Tue, 12 Apr 2011 18:03:00 +0000</pubDate><atom:updated>2011-04-12T20:22:49.618+02:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>Performance schema FAQ #1, enable without a server restart</title><description>&lt;p&gt;Q: Is it possible to enable / disable the performance schema at runtime ?&lt;/p&gt;
&lt;p&gt;A: Yes.&lt;/p&gt;
&lt;h2&gt;Configure, configure and configure&lt;/h2&gt;
&lt;p&gt;The performance schema is affected by three distinct set of configuration parameters, that take effect at compile time, server startup, or runtime.&lt;/p&gt;
&lt;h3&gt;Compile time options&lt;/h3&gt;
&lt;p&gt;When building from the source code, make sure the cmake flag 'WITH_PERFSCHEMA_STORAGE_ENGINE' is set to 'ON' (it is by default).&lt;/p&gt;
&lt;p&gt;For packages built by Oracle, the performance schema is included by default.&lt;/p&gt;
&lt;h3&gt;Server startup options&lt;/h3&gt;
&lt;p&gt;Simply add the 'performance_schema' option to your my.cnf configuration file.&lt;/p&gt;
&lt;p&gt;The effect of this option seems mis understood, leading people to think that the performance schema can only be enabled or disabled at server startup time, which is not the case.&lt;/p&gt;
&lt;p&gt;The role of this startup option, with the related sizing parameters, is to initialize the performance schema internal memory buffers, and hook the performance schema instrumentation to the server and or plugins, so that everything is 'ready to go'. Note that 'ready to go' does not means 'enabled', it just means that things can be enabled or disabled later at runtime.&lt;/p&gt;
&lt;h3&gt;Runtime configuration&lt;/h3&gt;
&lt;p&gt;When the performance schema component is active in the server, it is listening to all events. Performance schema 'consumers' will decide, based on the content of the various setup tables in the performance_schema database, what to do with the event that just happened in the server code.&lt;/p&gt;
&lt;p&gt;A table, performance_schema.setup_consumers, shows all the consumers available. This table has a ENABLED column that can be updated, giving the DBA full control on the internal performance schema execution flow.&lt;/p&gt;
&lt;p&gt;There is a consumer which effectively controls globally all the data collection, so by turning this consumer ON or OFF, the entire performance schema instrumentation can be turned on or off, dynamically.&lt;/p&gt;
&lt;p&gt;In 5.5, this consumer is named 'events_waits_current'. Note that this consumer in fact has two roles, as it controls both the overall data collection, and also the output table performance_schema.events_waits_current. This is a limitation, as there is no way to collect performance schema data independently of table events_waits_current.&lt;/p&gt;
&lt;p&gt;In 5.6, this limitation has been lifted, so that the consumer which effectively control data collection is 'global_instrumentation', while the consumer named 'events_waits_current' controls only the table of the same name. The new consumer 'global_instrumentation' in 5.6 is the result of significant performance optimizations implemented in the code, made possible by decoupling the overall data collection from table events_waits_current.&lt;/p&gt;
&lt;h2&gt;Cheat sheet for mysql-5.5&lt;/h2&gt;
&lt;p&gt;To enable the performance schema at runtime (5.5), use the following query:&lt;p&gt;
&lt;pre&gt;
mysql&gt; update performance_schema.setup_consumers set enabled='YES' where name='events_waits_current';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql&gt; select * from performance_schema.setup_consumers;
+----------------------------------------------+---------+
| NAME                                         | ENABLED |
+----------------------------------------------+---------+
| events_waits_current                         | YES     |
| ...                                            ...     |
+----------------------------------------------+---------+
8 rows in set (0.01 sec)
&lt;/pre&gt;
&lt;p&gt;To disable the performance schema at runtime (5.5), use the following query:&lt;p&gt;
&lt;pre&gt;
mysql&gt; update performance_schema.setup_consumers set enabled='NO' where name='events_waits_current';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql&gt; select * from performance_schema.setup_consumers;
+----------------------------------------------+---------+
| NAME                                         | ENABLED |
+----------------------------------------------+---------+
| events_waits_current                         | NO      |
| ...                                            ...     |
+----------------------------------------------+---------+
8 rows in set (0.01 sec)
&lt;/pre&gt;
&lt;h2&gt;Cheat sheet for mysql-5.6&lt;/h2&gt;
&lt;p&gt;To disable the performance schema at runtime (5.6), use the following query:&lt;p&gt;
&lt;pre&gt;
update performance_schema.setup_consumers set enabled='NO' where name='global_instrumentation';
&lt;/pre&gt;
&lt;p&gt;To enable the performance schema at runtime (5.6), use the following query:&lt;p&gt;
&lt;pre&gt;
mysql&gt; update performance_schema.setup_consumers set enabled='YES' where name='global_instrumentation';
&lt;/pre&gt;

&lt;p&gt;Enjoy !&lt;/p&gt;

&lt;p&gt;Marc Alff, Oracle.&lt;/p&gt;</description><link>http://marcalff.blogspot.com/2011/04/performance-schema-faq-1-enable-without.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-1327620741847129260</guid><pubDate>Thu, 24 Mar 2011 12:28:00 +0000</pubDate><atom:updated>2011-03-24T14:12:56.035+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>The PERFORMANCE SCHEMA development continues</title><description>&lt;p&gt;Now that mysql 5.5 is GA, development for the performance schema continues in the mysql-trunk code base. A lot of projects have been completed already, which are worth mentioning.&lt;/p&gt;
&lt;h2&gt;New table io instrumentation&lt;/h2&gt;
&lt;p&gt;Table io is now instrumented. As the performance instrumentation is located in the MySQL layer and not inside the storage engine, this instrumentation is de facto available to all storage engines, with zero code change.&lt;/p&gt;
&lt;h2&gt;New table lock instrumentation&lt;/h2&gt;
&lt;p&gt;Table locks are also instrumented. It is a nice complement to table io, and can be enabled or disabled independently from table io. Not all table waits are io problems, some are also contention caused by locks ... and there is now a way to observe that.&lt;/p&gt;
&lt;h2&gt;New stages instrumentation&lt;/h2&gt;
&lt;p&gt;Major execution phases of a statement, called stages, are now instrumented. This instrumentation is critical to identify which part of the execution path (parser, acl, locking, optimizer, runtime, etc) takes time.&lt;/p&gt;
&lt;h2&gt;New statements instrumentation&lt;/h2&gt;
&lt;p&gt;Statements themselves are now instrumented. As statements are what an application sends to the server, this is the instrumentation that makes the most sense to application developers. Now, once a statement is found to be "too slow", the lower level instrumentation like stage and waits can be used to see why.&lt;/p&gt;
&lt;h2&gt;New filtering options&lt;/h2&gt;
&lt;p&gt;A DBA may not want to monitor every single user session from every single application from every single host at once. Instrumentation for each session (or thread) can be turned on of off independently (TABLE performance_schema.threads, column INSTRUMENTED). Rules in the new table performance_schema.setup_actors can be used to instrument selectively traffic per user, per host, or per user+host.&lt;/p&gt;
&lt;p&gt;Likewise, with table io and table lock instrumentation, a DBA may not want to instrument every single table in the database at once, but only instrument a subset of tables. Rules in the new tables performance_schema.setup_objects can be used for that.&lt;/p&gt;

Marc Alff,
Oracle.</description><link>http://marcalff.blogspot.com/2011/03/performance-schema-development.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-4208697092090489186</guid><pubDate>Sat, 04 Dec 2010 15:35:00 +0000</pubDate><atom:updated>2010-12-04T19:54:12.475+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>The PERFORMANCE SCHEMA is dead, long live the performance schema</title><description>&lt;h2&gt;The PERFORMANCE SCHEMA is dead&lt;/h2&gt;
&lt;p&gt;The initial implementation of the performance schema used to name tables in the performance schema database in UPPERCASE, as in 'EVENTS_WAITS_CURRENT'.&lt;/p&gt;
&lt;p&gt;This naming scheme turned up to be difficult to work with (see &lt;a href="http://bugs.mysql.com/bug.php?id=57609"&gt;Bug#57609&lt;/a&gt;), especially considering the established MySQL practice of converting table names to lowercase, using the &lt;a href="http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_lower_case_table_names"&gt;lower_case_table_names&lt;/a&gt; server setting.&lt;/p&gt;
&lt;h2&gt;Long live the performance schema&lt;/h2&gt;
&lt;p&gt;Starting with MySQL 5.5.8, the performance schema tables have been renamed to lowercase.&lt;/p&gt;
&lt;p&gt;This guarantees that a query such as 'select * from performance_schema.events_waits_current' will work consistently across any server deployment, regardless of the server platform or the server lower_case_table_names configuration parameter.&lt;/p&gt;
&lt;p&gt;Life for people or automated tools using the performance schema just became much easier ...&lt;/p&gt;
Marc Alff,
Oracle.</description><link>http://marcalff.blogspot.com/2010/12/performance-schema-is-dead-long-live.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-5795376106083323631</guid><pubDate>Mon, 08 Mar 2010 15:15:00 +0000</pubDate><atom:updated>2010-03-08T16:41:27.305+01:00</atom:updated><title>MySQL Performance Schema is in the trunk</title><description>&lt;h2&gt;It is in&lt;/h2&gt;
&lt;p&gt;As of 2010-03-06, the performance schema is merged into MySQL version 5.5.3-m3, in &lt;a href="https://code.launchpad.net/~mysql/mysql-server/mysql-trunk"&gt;mysql-trunk&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The documentation for 5.5 has also been updated, and contains a new &lt;a href="http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html"&gt;MySQL Performance Schema chapter&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Disclaimer&lt;/h2&gt;
&lt;p&gt;Please note that MySQL 5.5 is not a GA product. The performance schema feature may still change at any time, for any reason, and without notice. Customers should not make purchasing decisions based on the availability of the performance schema.&lt;/p&gt;

Marc Alff,
Oracle.</description><link>http://marcalff.blogspot.com/2010/03/mysql-performance-schema-is-in-trunk.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-1559905463192401345.post-6470863137371609912</guid><pubDate>Thu, 21 Jan 2010 07:25:00 +0000</pubDate><atom:updated>2010-01-21T08:33:05.037+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>PERFORMANCE_SCHEMA</category><title>Performance schema overview</title><description>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt; This paper is an introduction to the new 'performance schema' feature, which will be part of the upcoming MySQL 5.5 release.  Covering in details every part of the performance schema would require much, much more than a simple article.  The pace of this teaser is voluntarily fast, to have a quick overview of the new landscape, and help users already familiar with MySQL to understand by examples what the performance schema provides.&lt;/p&gt;
&lt;p&gt; Please refer to the online documentation in &lt;a href="http://dev.mysql.com/doc/performance-schema/en/index.html"&gt;the MySQL manual&lt;/a&gt; for more content.&lt;/p&gt;

&lt;h2&gt;Basic setup&lt;/h2&gt;
&lt;p&gt; Let's start a server, and a client connection for monitoring.&lt;/p&gt;
&lt;pre&gt;
mysql&amp;gt; select version();
+---------------------+
| version()           |
+---------------------+
| 5.5.99-m3-debug-log |
+---------------------+
1 row in set (0.00 sec)

mysql&amp;gt; prompt Monitor&amp;gt; ;
PROMPT set to 'Monitor&amp;gt; '
Monitor&amp;gt; &lt;/pre&gt;

&lt;p&gt; Start two other clients, and set the prompt to identify them.  &lt;/p&gt;
&lt;pre&gt;
mysql&amp;gt; select connection_id();
+-----------------+
| connection_id() |
+-----------------+
|               2 |
+-----------------+
1 row in set (0.00 sec)

mysql&amp;gt; prompt Client A (ID 2)&amp;gt; ;
PROMPT set to 'Client A (ID 2)&amp;gt; '
Client A (ID 2)&amp;gt; &lt;/pre&gt;
&lt;pre&gt;
mysql&amp;gt; select connection_id();
+-----------------+
| connection_id() |
+-----------------+
|               3 |
+-----------------+
1 row in set (0.00 sec)

mysql&amp;gt; prompt Client B (ID 3)&amp;gt; ;
PROMPT set to 'Client B (ID 3)&amp;gt; '
Client B (ID 3)&amp;gt; &lt;/pre&gt;

&lt;h2&gt;Performance schema visible artifacts&lt;/h2&gt;
&lt;p&gt; There is a new storage engine.  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| ndbcluster         | NO      | Clustered, fault-tolerant tables                               | NULL         | NULL | NULL       |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MyISAM             | DEFAULT | Default engine as of MySQL 3.23 with great performance         | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
&lt;span class="red"&gt;| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |&lt;/span&gt;
| InnoDB             | NO      | Supports transactions, row-level locking, and foreign keys     | NULL         | NULL | NULL       |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec) &lt;/pre&gt;
&lt;p&gt; There is a new database.  &lt;/p&gt;
&lt;pre&gt;

Monitor&amp;gt; show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mtr                |
| mysql              |
&lt;span class="red"&gt;| performance_schema |&lt;/span&gt;
| test               |
+--------------------+
5 rows in set (0.00 sec) &lt;/pre&gt;
&lt;p&gt; Some new system variables are also available.  Every system variable can be set on the server command line options, or set in the my.cnf configuration file.  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; show variables like "performance_schema%";
+---------------------------------------------------+--------+
| Variable_name                                     | Value  |
+---------------------------------------------------+--------+
| performance_schema                                | ON     |
| performance_schema_events_waits_history_long_size | 10000  |
| performance_schema_events_waits_history_size      | 10     |
| performance_schema_max_cond_classes               | 80     |
| performance_schema_max_cond_instances             | 1000   |
| performance_schema_max_file_classes               | 50     |
| performance_schema_max_file_handles               | 32768  |
| performance_schema_max_file_instances             | 10000  |
| performance_schema_max_mutex_classes              | 200    |
| performance_schema_max_mutex_instances            | 1000   |
| performance_schema_max_rwlock_classes             | 20     |
| performance_schema_max_rwlock_instances           | 1000   |
| performance_schema_max_table_handles              | 100000 |
| performance_schema_max_table_instances            | 50000  |
| performance_schema_max_thread_classes             | 50     |
| performance_schema_max_thread_instances           | 1000   |
+---------------------------------------------------+--------+
16 rows in set (0.01 sec) &lt;/pre&gt;
&lt;p&gt; There are also status variables, to inspect the internal performance schema status.  &lt;/p&gt;

&lt;pre&gt;
Monitor&amp;gt; show status like "performance_schema%";
+------------------------------------------+-------+
| Variable_name                            | Value |
+------------------------------------------+-------+
| Performance_schema_cond_classes_lost     | 0     |
| Performance_schema_cond_instances_lost   | 0     |
| Performance_schema_file_classes_lost     | 0     |
| Performance_schema_file_handles_lost     | 0     |
| Performance_schema_file_instances_lost   | 0     |
| Performance_schema_locker_lost           | 0     |
| Performance_schema_mutex_classes_lost    | 0     |
| Performance_schema_mutex_instances_lost  | 0     |
| Performance_schema_rwlock_classes_lost   | 0     |
| Performance_schema_rwlock_instances_lost | 0     |
| Performance_schema_table_handles_lost    | 0     |
| Performance_schema_table_instances_lost  | 0     |
| Performance_schema_thread_classes_lost   | 0     |
| Performance_schema_thread_instances_lost | 0     |
+------------------------------------------+-------+
14 rows in set (0.00 sec) &lt;/pre&gt;
&lt;p&gt; SHOW ENGINE STATUS can also be used to inspect the performance schema internal state.  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; show engine PERFORMANCE_SCHEMA status;
+--------------------+--------------------------------------------------------+----------+
| Type               | Name                                                   | Status   |
+--------------------+--------------------------------------------------------+----------+
| performance_schema | EVENTS_WAITS_CURRENT.ROW_SIZE                          | 136      |
| performance_schema | EVENTS_WAITS_CURRENT.ROW_COUNT                         | 3000     |
| performance_schema | EVENTS_WAITS_HISTORY.ROW_SIZE                          | 120      |
| performance_schema | EVENTS_WAITS_HISTORY.ROW_COUNT                         | 10000    |
| performance_schema | EVENTS_WAITS_HISTORY.MEMORY                            | 1200000  |
| performance_schema | EVENTS_WAITS_HISTORY_LONG.ROW_SIZE                     | 120      |
| performance_schema | EVENTS_WAITS_HISTORY_LONG.ROW_COUNT                    | 10000    |
| performance_schema | EVENTS_WAITS_HISTORY_LONG.MEMORY                       | 1200000  |
| performance_schema | (PFS_MUTEX_CLASS).ROW_SIZE                             | 248      |
| performance_schema | (PFS_MUTEX_CLASS).ROW_COUNT                            | 200      |
| performance_schema | (PFS_MUTEX_CLASS).MEMORY                               | 49600    |
...
| performance_schema | EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.ROW_SIZE  | 48       |
| performance_schema | EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.ROW_COUNT | 350000   |
| performance_schema | EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.MEMORY    | 16800000 |
| performance_schema | PERFORMANCE_SCHEMA.MEMORY                              | 26459600 |
+--------------------+--------------------------------------------------------+----------+
45 rows in set (0.00 sec) &lt;/pre&gt;
&lt;p&gt; Let's see what is in the new performance_schema database ...  &lt;/p&gt;
&lt;pre&gt;

Monitor&amp;gt; use performance_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
Monitor&amp;gt; show tables;
+----------------------------------------------+
| Tables_in_performance_schema                 |
+----------------------------------------------+
| COND_INSTANCES                               |
| EVENTS_WAITS_CURRENT                         |
| EVENTS_WAITS_HISTORY                         |
| EVENTS_WAITS_HISTORY_LONG                    |
| EVENTS_WAITS_SUMMARY_BY_EVENT_NAME           |
| EVENTS_WAITS_SUMMARY_BY_INSTANCE             |
| EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME |
| FILE_INSTANCES                               |
| FILE_SUMMARY_BY_EVENT_NAME                   |
| FILE_SUMMARY_BY_INSTANCE                     |
| MUTEX_INSTANCES                              |
| PERFORMANCE_TIMERS                           |
| PROCESSLIST                                  |
| RWLOCK_INSTANCES                             |
| SETUP_CONSUMERS                              |
| SETUP_INSTRUMENTS                            |
| SETUP_OBJECTS                                |
| SETUP_TIMERS                                 |
+----------------------------------------------+
18 rows in set (0.00 sec) &lt;/pre&gt;
&lt;h2&gt;What is instrumented in the code ?&lt;/h2&gt;
&lt;p&gt; The available instrumentation is discovered dynamically.&lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; select * from SETUP_INSTRUMENTS;
+------------------------------------------------------------+---------+-------+
| NAME                                                       | ENABLED | TIMED |
+------------------------------------------------------------+---------+-------+
| wait/synch/mutex/sql/PAGE::lock                            | YES     | YES   |
| wait/synch/mutex/sql/TC_LOG_MMAP::LOCK_sync                | YES     | YES   |
| wait/synch/mutex/sql/TC_LOG_MMAP::LOCK_active              | YES     | YES   |
| wait/synch/mutex/sql/TC_LOG_MMAP::LOCK_pool                | YES     | YES   |
| wait/synch/mutex/sql/LOCK_des_key_file                     | YES     | YES   |
| wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_index             | YES     | YES   |
| wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_prep_xids         | YES     | YES   |
| wait/synch/mutex/sql/Delayed_insert::mutex                 | YES     | YES   |
...
| wait/synch/rwlock/sql/LOCK_grant                           | YES     | YES   |
| wait/synch/rwlock/sql/LOGGER::LOCK_logger                  | YES     | YES   |
| wait/synch/rwlock/sql/LOCK_sys_init_connect                | YES     | YES   |
| wait/synch/rwlock/sql/LOCK_sys_init_slave                  | YES     | YES   |
| wait/synch/rwlock/sql/LOCK_system_variables_hash           | YES     | YES   |
| wait/synch/rwlock/sql/Query_cache_query::lock              | YES     | YES   |
| wait/synch/rwlock/sql/LOCK_dboptions                       | YES     | YES   |
| wait/synch/rwlock/myisam/MYISAM_SHARE::key_root_lock       | YES     | YES   |
| wait/synch/rwlock/myisam/MYISAM_SHARE::mmap_lock           | YES     | YES   |
...
| wait/synch/cond/sql/COND_flush_thread_cache                | YES     | YES   |
| wait/synch/cond/mysys/COND_alarm                           | YES     | YES   |
| wait/synch/cond/mysys/IO_CACHE_SHARE::cond                 | YES     | YES   |
| wait/synch/cond/mysys/IO_CACHE_SHARE::cond_writer          | YES     | YES   |
| wait/synch/cond/mysys/my_thread_var::suspend               | YES     | YES   |
| wait/synch/cond/mysys/THR_COND_threads                     | YES     | YES   |
...
| wait/io/file/csv/metadata                                  | YES     | YES   |
| wait/io/file/csv/data                                      | YES     | YES   |
| wait/io/file/csv/update                                    | YES     | YES   |
| wait/io/file/myisam/data_tmp                               | YES     | YES   |
| wait/io/file/myisam/dfile                                  | YES     | YES   |
| wait/io/file/myisam/kfile                                  | YES     | YES   |
| wait/io/file/myisam/log                                    | YES     | YES   |
| wait/io/file/myisammrg/MRG                                 | YES     | YES   |
+------------------------------------------------------------+---------+-------+
167 rows in set (0.00 sec) &lt;/pre&gt;
&lt;p&gt; So, for this platform, 167 artifacts in the server and storage engines are instrumented.  Let's see the breakdown by type.  &lt;/p&gt;

&lt;pre&gt;
Monitor&amp;gt; select count(*) from SETUP_INSTRUMENTS where name like 'wait/synch/mutex/%';
+----------+
| count(*) |
+----------+
|       84 |
+----------+
1 row in set (0.00 sec)

Monitor&amp;gt; select count(*) from SETUP_INSTRUMENTS where name like 'wait/synch/cond/%';
+----------+
| count(*) |
+----------+
|       35 |
+----------+
1 row in set (0.00 sec)

Monitor&amp;gt; select count(*) from SETUP_INSTRUMENTS where name like 'wait/synch/rwlock/%';
+----------+
| count(*) |
+----------+
|       11 |
+----------+
1 row in set (0.00 sec)

Monitor&amp;gt; select count(*) from SETUP_INSTRUMENTS where name like 'wait/io/file/%';
+----------+
| count(*) |
+----------+
|       37 |
+----------+
1 row in set (0.00 sec) &lt;/pre&gt;
&lt;h2&gt;What is running inside the server ?&lt;/h2&gt;
&lt;p&gt; The existing SHOW PROCESSLIST command can be used to see that ...  &lt;/p&gt;
&lt;pre&gt;

Monitor&amp;gt; show processlist;
+----+------+-----------+--------------------+---------+------+-------+------------------+
| Id | User | Host      | db                 | Command | Time | State | Info             |
+----+------+-----------+--------------------+---------+------+-------+------------------+
|  1 | root | localhost | performance_schema | Query   |    0 | NULL  | show processlist |
|  2 | root | localhost | NULL               | Sleep   | 3459 |       | NULL             |
|  3 | root | localhost | NULL               | Sleep   | 3386 |       | NULL             |
+----+------+-----------+--------------------+---------+------+-------+------------------+
3 rows in set (0.00 sec) &lt;/pre&gt;
&lt;p&gt; Ok, nice try. Now, what is &lt;em&gt;really&lt;/em&gt; running in the server ?  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; select * from PROCESSLIST;
+-----------+----+---------------------------+
| THREAD_ID | ID | NAME                      |
+-----------+----+---------------------------+
|         0 |  0 | thread/sql/main           |
|         3 |  2 | thread/sql/one_connection |
|         4 |  3 | thread/sql/one_connection |
|         2 |  1 | thread/sql/one_connection |
|         1 |  0 | thread/sql/signal_handler |
+-----------+----+---------------------------+
5 rows in set (0.00 sec) &lt;/pre&gt;
&lt;p&gt; Here we see two new threads that were previously hidden.  Every thread instrumented in the code is displayed by the performance schema.  This include for example, threads used internally by a storage engine.  &lt;/p&gt;

&lt;p&gt; We know Client A connection_id() is 2, let's find out what thread is executing Client A requests.  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; select * from PROCESSLIST where ID=2;
+-----------+----+---------------------------+
| THREAD_ID | ID | NAME                      |
+-----------+----+---------------------------+
|         3 |  2 | thread/sql/one_connection |
+-----------+----+---------------------------+
1 row in set (0.00 sec) &lt;/pre&gt;
&lt;h2&gt;What is this query waiting for, right now ?&lt;/h2&gt;
&lt;p&gt; First, we need a query that takes some time.  For illustration, let's make client A sleep for 10 seconds.  &lt;/p&gt;
&lt;pre&gt;
Client A (ID 2)&amp;gt; select sleep(10); &lt;/pre&gt;

&lt;p&gt; While the query is still executing, see what event the code is waiting for.  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; select * from EVENTS_WAITS_CURRENT where THREAD_ID=3\G
*************************** 1. row ***************************
            THREAD_ID: 3
             EVENT_ID: 46
&lt;span class="red"&gt;           EVENT_NAME: wait/synch/cond/sql/Item_func_sleep::cond&lt;/span&gt;
&lt;span class="red"&gt;               SOURCE: item_func.cc:3527&lt;/span&gt;
          TIMER_START: 5617352941894736
            TIMER_END: NULL
&lt;span class="red"&gt;           TIMER_WAIT: NULL&lt;/span&gt;

                SPINS: NULL
        OBJECT_SCHEMA: NULL
          OBJECT_NAME: NULL
          OBJECT_TYPE: NULL
OBJECT_INSTANCE_BEGIN: 139803207157216
     NESTING_EVENT_ID: NULL
&lt;span class="red"&gt;            OPERATION: timed_wait&lt;/span&gt;
      NUMBER_OF_BYTES: NULL
                FLAGS: 0
1 row in set (0.00 sec) &lt;/pre&gt;
&lt;p&gt; Looking at the results, we can tell that the query is still waiting (TIMER_WAIT is NULL) for an instrumented condition (EVENT_NAME starts with 'wait/synch/cond/'), which is located in the sql layer ('sql/'), and happen to be named 'Item_func_sleep::cond'.  The instrumented call is located in file item_func.cc, line 3527 (SOURCE), and the call was a 'timed_wait' (OPERATION).  &lt;/p&gt;
&lt;h2&gt;What are the recent wait events of this connection ?&lt;/h2&gt;
&lt;p&gt; After the sleep(10) is completed, let's look at the wait history for Client A connection.  &lt;/p&gt;
&lt;pre&gt;

Monitor&amp;gt; select THREAD_ID, EVENT_ID, EVENT_NAME, SOURCE, TIMER_WAIT, OBJECT_INSTANCE_BEGIN, OPERATION from EVENTS_WAITS_HISTORY where THREAD_ID=3 order by THREAD_ID, EVENT_ID;
+-----------+----------+---------------------------------------------+--------------------+---------------+-----------------------+------------+
| THREAD_ID | EVENT_ID | EVENT_NAME                                  | SOURCE             | TIMER_WAIT    | OBJECT_INSTANCE_BEGIN | OPERATION  |
+-----------+----------+---------------------------------------------+--------------------+---------------+-----------------------+------------+
|         3 |       43 | wait/synch/mutex/mysys/THR_LOCK_malloc      | safemalloc.c:181   |        399243 |              18775392 | lock       |
|         3 |       44 | wait/synch/mutex/mysys/THR_LOCK_malloc      | safemalloc.c:294   |        210035 |              18775392 | lock       |
|         3 |       45 | wait/synch/mutex/sql/LOCK_user_locks        | item_func.cc:3837  |        500907 |              18580768 | lock       |
|         3 |       46 | wait/synch/cond/sql/Item_func_sleep::cond   | item_func.cc:3527  | 5000241974790 |       140221896639968 | timed_wait |
|         3 |       47 | wait/synch/cond/sql/Item_func_sleep::cond   | item_func.cc:3527  | 5000237350843 |       140221896639968 | timed_wait |
|         3 |       48 | wait/synch/mutex/mysys/my_thread_var::mutex | item_func.cc:3853  |        612102 |              19805600 | lock       |
|         3 |       49 | wait/synch/mutex/sql/LOCK_plugin            | sql_plugin.cc:1013 |        356883 |              18701152 | lock       |
|         3 |       50 | wait/synch/rwlock/sql/LOGGER::LOCK_logger   | log.h:582          |        276046 |              18672512 | read_lock  |
|         3 |       51 | wait/synch/mutex/sql/LOG::LOCK_log          | log.cc:2515        |        372062 |              18989864 | lock       |
|         3 |       52 | wait/synch/mutex/sql/THD::LOCK_thd_data     | sql_class.cc:3267  |        276046 |              19798240 | lock       |
+-----------+----------+---------------------------------------------+--------------------+---------------+-----------------------+------------+
10 rows in set (0.00 sec) &lt;/pre&gt;
&lt;p&gt; It seems the wait for 10 seconds was interupted, so the code instead waited twice for 5 seconds, in the timed_wait.  &lt;/p&gt;
&lt;h2&gt;What timer is used to measure all that ?&lt;/h2&gt;
&lt;p&gt; The performance schema provide different timers, with different characteristics.  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; select * from PERFORMANCE_TIMERS;
+-------------+-----------------+------------------+----------------+
| TIMER_NAME  | TIMER_FREQUENCY | TIMER_RESOLUTION | TIMER_OVERHEAD |
+-------------+-----------------+------------------+----------------+
| CYCLE       |      2830706467 |                1 |             43 |
| NANOSECOND  |            NULL |             NULL |           NULL |
| MICROSECOND |         1000000 |                1 |            119 |
| MILLISECOND |            1037 |                1 |            128 |
| TICK        |             103 |                1 |            451 |
+-------------+-----------------+------------------+----------------+
5 rows in set (0.00 sec) &lt;/pre&gt;

&lt;p&gt; The CYCLE timer shows that this machine has a 2.83 GHz CPU.  The NANOSECOND timer is not available.  Which timer to pick is configurable.  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; select * from SETUP_TIMERS;
+------+------------+
| NAME | TIMER_NAME |
+------+------------+
| wait | CYCLE      |
+------+------------+
1 row in set (0.00 sec) &lt;/pre&gt;
&lt;h2&gt;Looking at history for a longer period&lt;/h2&gt;
&lt;p&gt; Let's use a sample scenario to illustrate how to use the history tables.  First, we need some objects to use in queries.  &lt;/p&gt;
&lt;pre&gt;
Client A (ID 2)&amp;gt; create table test.t1(a int);
Query OK, 0 rows affected (0.07 sec)

Client A (ID 2)&amp;gt; lock table test.t1 read;
Query OK, 0 rows affected (0.00 sec) &lt;/pre&gt;

&lt;p&gt; Get a timestamp, we will analyse the history from now on.  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; select max(TIMER_START) from EVENTS_WAITS_HISTORY into @marker_begin;
Query OK, 1 row affected (0.00 sec)

Monitor&amp;gt; select @marker_begin;
+------------------+
| @marker_begin    |
+------------------+
| 2461829402934558 |
+------------------+
1 row in set (0.00 sec) &lt;/pre&gt;
&lt;p&gt; Now the scenario itself: Client B will try to insert a row, and will be blocked.  Client A will then unlock tables, unblocking B, which will finish.  &lt;/p&gt;
&lt;pre&gt;
Client B (ID 3)&amp;gt; insert into test.t1 values (1); &lt;/pre&gt;

&lt;pre&gt;
Client A (ID 2)&amp;gt; unlock tables;
Query OK, 0 rows affected (0.00 sec) &lt;/pre&gt;
&lt;pre&gt;
Query OK, 1 row affected (12.98 sec) &lt;/pre&gt;
&lt;p&gt; Get a timestamp again, and let's see what happened with clients A and B ...  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; select max(TIMER_START) from EVENTS_WAITS_HISTORY into @marker_end;
Query OK, 1 row affected (0.00 sec)

Monitor&amp;gt; select @marker_end;
+------------------+
| @marker_end      |
+------------------+
| 2928891716761738 |
+------------------+
1 row in set (0.00 sec)

Monitor&amp;gt; select THREAD_ID, EVENT_ID, EVENT_NAME, SOURCE, TIMER_START, TIMER_WAIT, OBJECT_INSTANCE_BEGIN, OPERATION
    -&amp;gt; from EVENTS_WAITS_HISTORY_LONG where (THREAD_ID=3 or THREAD_ID=4) and
    -&amp;gt; (TIMER_START &amp;gt; @marker_begin) and (TIMER_START &amp;lt;= @marker_end)
    -&amp;gt; order by TIMER_START asc;
+-----------+----------+---------------------------------------------------------+--------------------+------------------+----------------+-----------------------+-----------+               
| THREAD_ID | EVENT_ID | EVENT_NAME                                              | SOURCE             | TIMER_START      | TIMER_WAIT     | OBJECT_INSTANCE_BEGIN | OPERATION |               
+-----------+----------+---------------------------------------------------------+--------------------+------------------+----------------+-----------------------+-----------+               
|         4 |       39 | wait/synch/mutex/sql/THD::LOCK_thd_data                 | sql_class.cc:3287  | 2612399119180647 |        1338223 |              19855856 | lock      |               
|         4 |       40 | wait/synch/mutex/sql/THD::LOCK_thd_data                 | sql_class.cc:3267  | 2612399126078620 |         216036 |              19855856 | lock      |               
|         4 |       41 | wait/synch/rwlock/sql/LOGGER::LOCK_logger               | log.h:582          | 2612399129553199 |         321230 |              18672512 | read_lock |               
|         4 |       42 | wait/synch/mutex/sql/LOG::LOCK_log                      | log.cc:2414        | 2612399134753242 |         458900 |              18988648 | lock      |               
|         4 |       43 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:294   | 2612399222016607 |         390065 |              18775392 | lock      |               
|         4 |       44 | wait/synch/rwlock/sql/LOCK_grant                        | sql_acl.cc:3990    | 2612399231231319 |         144024 |              18595168 | read_lock |               
|         4 |       45 | wait/synch/mutex/sql/LOCK_global_read_lock              | lock.cc:1513       | 2612399233796570 |         369238 |              18593248 | lock      |               
|         4 |       46 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:181   | 2612399239800747 |         224861 |              18775392 | lock      |
|         4 |       47 | wait/synch/mutex/sql/LOCK_open                          | sql_base.cc:2745   | 2612399244679560 |         318053 |              18592864 | lock      |
|         4 |       48 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:181   | 2612399248817073 |         213212 |              18775392 | lock      |
|         4 |       49 | wait/synch/mutex/sql/TABLE_SHARE::mutex                 | sql_base.cc:404    | 2612399251601537 |         258043 |              19549224 | lock      |
|         4 |       50 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:181   | 2612399255052112 |         210035 |              18775392 | lock      |
|         4 |       51 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:181   | 2612399258115799 |         206858 |              18775392 | lock      |
|         4 |       52 | wait/synch/mutex/mysys/THR_LOCK_myisam                  | mi_open.c:106      | 2612399299375498 |         390065 |              18775520 | lock      |
|         4 |       53 | wait/io/file/myisam/dfile                               | mi_open.c:1271     | 2612399310495351 |        9763627 |       140221840474240 | open      |
|         4 |       54 | wait/synch/mutex/mysys/THR_LOCK_open                    | my_open.c:137      | 2612399317282482 |         429248 |              18775008 | lock      |
|         4 |       55 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:181   | 2612399318713897 |         212859 |              18775392 | lock      |
|         4 |       56 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:181   | 2612399322194477 |         206858 |              18775392 | lock      |
|         4 |       57 | wait/synch/mutex/myisam/MYISAM_SHARE::intern_lock       | mi_open.c:620      | 2612399323862755 |         320877 |              19920280 | lock      |
|         4 |       58 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:181   | 2612399325593867 |         207211 |              18775392 | lock      |
|         4 |       59 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:181   | 2612399328546359 |         204034 |              18775392 | lock      |
|         4 |       60 | wait/synch/mutex/sql/TABLE_SHARE::mutex                 | ha_myisam.cc:1712  | 2612399334115287 |         282047 |              19549224 | lock      |
|         4 |       61 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:294   | 2612399342195810 |         210035 |              18775392 | lock      |
|         4 |       62 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:294   | 2612399364672379 |         255219 |              18775392 | lock      |
|         4 |       63 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:181   | 2612399369764404 |         252042 |              18775392 | lock      |
|         4 |       64 | wait/synch/mutex/myisam/MYISAM_SHARE::intern_lock       | mi_locking.c:53    | 2612399372932932 |         224861 |              19920280 | lock      |
|         4 |       65 | wait/synch/mutex/mysys/THR_LOCK::mutex                  | thr_lock.c:525     | 2612399376764394 |         237216 |              19920048 | lock      |
|         4 |       66 | wait/synch/cond/mysys/my_thread_var::suspend            | thr_lock.c:444     | 2612399380827071 | 12977803964893 |              19864808 | wait      |
|         3 |      199 | wait/synch/mutex/sql/THD::LOCK_thd_data                 | sql_class.cc:3287  | 2625377031586434 |        1311395 |              19798240 | lock      |
|         3 |      200 | wait/synch/mutex/sql/THD::LOCK_thd_data                 | sql_class.cc:3267  | 2625377038712798 |         212859 |              19798240 | lock      |
|         3 |      201 | wait/synch/rwlock/sql/LOGGER::LOCK_logger               | log.h:582          | 2625377043456412 |         345234 |              18672512 | read_lock |
|         3 |      202 | wait/synch/mutex/sql/LOG::LOCK_log                      | log.cc:2414        | 2625377048476425 |         486081 |              18988648 | lock      |
|         3 |      203 | wait/synch/mutex/mysys/THR_LOCK::mutex                  | thr_lock.c:814     | 2625377120023171 |         456076 |              19920048 | lock      |
|         3 |      204 | wait/synch/mutex/myisam/MYISAM_SHARE::intern_lock       | mi_locking.c:53    | 2625377132169195 |         231215 |              19920280 | lock      |
|         3 |      205 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:294   | 2625377136297883 |         231215 |              18775392 | lock      |
|         3 |      206 | wait/synch/mutex/sql/LOCK_open                          | sql_base.cc:1201   | 2625377139598433 |         306051 |              18592864 | lock      |
|         3 |      207 | wait/synch/mutex/sql/LOCK_plugin                        | sql_plugin.cc:1013 | 2625377157094525 |         320877 |              18701152 | lock      |
|         3 |      208 | wait/synch/mutex/sql/THD::LOCK_thd_data                 | sql_class.cc:3267  | 2625377169918662 |         266868 |              19798240 | lock      |
|         4 |       67 | wait/synch/mutex/mysys/my_thread_var::mutex             | thr_lock.c:503     | 2625377197730120 |         648108 |              19864864 | lock      |
|         4 |       68 | wait/synch/rwlock/sql/LOCK_grant                        | sql_acl.cc:4266    | 2625377233568092 |         450075 |              18595168 | read_lock |
|         4 |       69 | wait/io/file/myisam/kfile                               | mi_locking.c:548   | 2625377256953989 |       23803143 |       140221840473616 | write     |
|         4 |       70 | wait/io/file/myisam/dfile                               | mi_dynrec.c:233    | 2625377283097522 |       32138179 |       140221840474240 | write     |
|         4 |       71 | wait/io/file/myisam/dfile                               | mi_dynrec.c:233    | 2625377316267873 |        3855819 |       140221840474240 | write     |
|         4 |       72 | wait/synch/mutex/sql/Query_cache::structure_guard_mutex | sql_cache.cc:523   | 2625377334778134 |         666111 |              18596216 | lock      |
|         4 |       73 | wait/synch/mutex/sql/Query_cache::structure_guard_mutex | sql_cache.cc:545   | 2625377336920491 |         206858 |              18596216 | lock      |
|         4 |       74 | wait/synch/mutex/sql/LOCK_global_read_lock              | lock.cc:1561       | 2625377342084175 |         342057 |              18593248 | lock      |
|         4 |       75 | wait/synch/mutex/sql/LOCK_plugin                        | sql_plugin.cc:1013 | 2625377346678117 |         416893 |              18701152 | lock      |
|         4 |       76 | wait/synch/mutex/mysys/THR_LOCK::mutex                  | thr_lock.c:814     | 2625377544669110 |         596923 |              19920048 | lock      |
|         4 |       77 | wait/synch/mutex/myisam/MYISAM_SHARE::intern_lock       | mi_locking.c:53    | 2625377550156848 |         429248 |              19920280 | lock      |
|         4 |       78 | wait/synch/mutex/mysys/KEY_CACHE::cache_lock            | mf_keycache.c:4115 | 2625377552830470 |         330055 |              18991320 | lock      |
|         4 |       79 | wait/io/file/myisam/kfile                               | mi_open.c:934      | 2625377557658098 |        4545934 |       140221840473616 | write     |
|         4 |       80 | wait/synch/mutex/mysys/THR_LOCK_malloc                  | safemalloc.c:294   | 2625377565252540 |         438073 |              18775392 | lock      |
|         4 |       81 | wait/synch/mutex/sql/LOCK_open                          | sql_base.cc:1201   | 2625377568201855 |         495259 |              18592864 | lock      |
|         4 |       82 | wait/synch/mutex/sql/THD::LOCK_thd_data                 | sql_class.cc:3267  | 2625377578982828 |         336056 |              19855856 | lock      |
+-----------+----------+---------------------------------------------------------+--------------------+------------------+----------------+-----------------------+-----------+
54 rows in set (0.02 sec) &lt;/pre&gt;

&lt;p&gt; Important things to notice:
&lt;ul&gt;
&lt;li&gt; client B (thread 4) executes events up to 66, and is blocked for 12 seconds in a wait.  &lt;/li&gt;
&lt;li&gt; client A (thread 3) executes events 199 to 208 &lt;/li&gt;
&lt;li&gt; client B (thread 4) then resumes execution.  &lt;/li&gt;
&lt;li&gt; Both threads are using a mutex named 'MYISAM_SHARE::intern_lock' in myisam.  &lt;/li&gt;
&lt;li&gt; Looking at (thread 4, event 64), and (thread 3, event 204), the mutex address is the same (OBJECT_INSTANCE_BEGIN).  &lt;/li&gt;

&lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt; There you have it: the two clients were competing on a table lock for a myisam table ...  This illustrate that very detailed data can be observed in the performance schema history tables, &lt;/p&gt;
&lt;h2&gt;What's the big picture ?&lt;/h2&gt;
&lt;p&gt; The performance schema maintains aggregates from the low level wait events collected, here are sample queries showing aggregates based on different criteria.  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; select * from EVENTS_WAITS_SUMMARY_BY_EVENT_NAME order by SUM_TIMER_WAIT desc limit 20;
+---------------------------------------------------+------------+----------------+----------------+----------------+----------------+
| EVENT_NAME                                        | COUNT_STAR | SUM_TIMER_WAIT | MIN_TIMER_WAIT | AVG_TIMER_WAIT | MAX_TIMER_WAIT |
+---------------------------------------------------+------------+----------------+----------------+----------------+----------------+
| wait/synch/cond/mysys/my_thread_var::suspend      |          1 | 12977803964893 | 12977803964893 | 12977803964893 | 12977803964893 |
| wait/io/file/sql/FRM                              |        605 |    61285161668 |         332879 |      101297787 |    44527633212 |
| wait/synch/mutex/mysys/THR_LOCK_malloc            |       2676 |      505940427 |         138023 |         189065 |        4560760 |
| wait/io/file/myisam/kfile                         |         82 |      406281114 |         459253 |        4954647 |      187585259 |
| wait/io/file/myisam/dfile                         |         50 |      149008360 |         621280 |        2980167 |       32138179 |
| wait/synch/cond/sql/COND_thread_count             |          1 |      140672618 |      140672618 |      140672618 |      140672618 |
| wait/synch/mutex/sql/THD::LOCK_thd_data           |        218 |      105269189 |         156026 |         482886 |        1569438 |
| wait/io/file/sql/casetest                         |         10 |       75699438 |        2265201 |        7569943 |       22200876 |
| wait/io/file/sql/pid                              |          3 |       65458555 |        4716786 |       21819518 |       35012658 |
| wait/io/file/sql/ERRMSG                           |          5 |       58504102 |        1422237 |       11700820 |       23653118 |
| wait/synch/mutex/mysys/THR_LOCK_open              |        249 |       58411263 |         147201 |         234583 |         636106 |
| wait/io/file/sql/dbopt                            |          9 |       58032847 |        2748458 |        6448094 |       11395899 |
| wait/synch/mutex/sql/LOCK_plugin                  |        271 |       54424481 |         144024 |         200828 |         543267 |
| wait/synch/mutex/sql/LOCK_open                    |        155 |       37872311 |         144024 |         244337 |         630105 |
| wait/synch/mutex/mysys/THR_LOCK::mutex            |        123 |       29474088 |         141200 |         239626 |         645284 |
| wait/io/file/sql/MYSQL_LOG                        |          4 |       29470558 |         732122 |        7367639 |       15266544 |
| wait/io/file/mysys/charset                        |          3 |       29210044 |        2685624 |        9736681 |       21207534 |
| wait/synch/mutex/sql/LOG::LOCK_log                |         72 |       23395428 |         234039 |         324936 |         486081 |
| wait/synch/rwlock/sql/LOGGER::LOCK_logger         |         73 |       18702646 |         117196 |         256200 |         945334 |
| wait/synch/mutex/sql/LOCK_global_system_variables |         54 |       13213849 |         152849 |         244700 |         483257 |
+---------------------------------------------------+------------+----------------+----------------+----------------+----------------+
20 rows in set (0.00 sec)

Monitor&amp;gt; select * from EVENTS_WAITS_SUMMARY_BY_INSTANCE order by SUM_TIMER_WAIT desc limit 20;
+----------------------------------------------+-----------------------+------------+----------------+----------------+----------------+----------------+
| EVENT_NAME                                   | OBJECT_INSTANCE_BEGIN | COUNT_STAR | SUM_TIMER_WAIT | MIN_TIMER_WAIT | AVG_TIMER_WAIT | MAX_TIMER_WAIT |
+----------------------------------------------+-----------------------+------------+----------------+----------------+----------------+----------------+
| wait/synch/cond/mysys/my_thread_var::suspend |              19864808 |          1 | 12977803964893 | 12977803964893 | 12977803964893 | 12977803964893 |
| wait/io/file/sql/FRM                         |       140221841262352 |         47 |    60087698477 |         332879 |     1278461669 |    44527633212 |
| wait/synch/mutex/mysys/THR_LOCK_malloc       |              18775392 |       2704 |      512769918 |         138023 |         189633 |        4560760 |
| wait/io/file/myisam/kfile                    |       140221840473616 |         15 |      267174404 |         705294 |       17811626 |      187585259 |
| wait/synch/cond/sql/COND_thread_count        |              18595424 |          1 |      140672618 |      140672618 |      140672618 |      140672618 |
| wait/synch/mutex/sql/THD::LOCK_thd_data      |              19232304 |        183 |       91473949 |         206858 |         499857 |        1626271 |
| wait/io/file/myisam/dfile                    |       140221840474240 |          6 |       68756281 |        3855819 |       11459380 |       32138179 |
| wait/io/file/sql/pid                         |       140221843119376 |          3 |       65458555 |        4716786 |       21819518 |       35012658 |
| wait/io/file/sql/FRM                         |       140221837128352 |         21 |       64639595 |         428895 |        3078075 |        8455409 |
| wait/io/file/sql/ERRMSG                      |       140221837099024 |          5 |       58504102 |        1422237 |       11700820 |       23653118 |
| wait/synch/mutex/mysys/THR_LOCK_open         |              18775008 |        249 |       58411263 |         147201 |         234583 |         636106 |
| wait/io/file/sql/FRM                         |       140221837118368 |         21 |       57031386 |         411245 |        2715780 |        6571095 |
| wait/synch/mutex/sql/LOCK_plugin             |              18701152 |        273 |       55084591 |         144024 |         201775 |         543267 |
| wait/io/file/sql/FRM                         |       140221837118992 |         21 |       54062656 |         404891 |        2574412 |        6213859 |
| wait/io/file/sql/FRM                         |       140221837123360 |         21 |       53900982 |         440897 |        2566713 |        5968171 |
| wait/io/file/sql/FRM                         |       140221837125232 |         21 |       52953177 |         399243 |        2521579 |        6217036 |
| wait/io/file/sql/FRM                         |       140221837123984 |         21 |       52554287 |         402067 |        2502585 |        6229038 |
| wait/io/file/sql/FRM                         |       140221837124608 |         21 |       52463213 |         426071 |        2498248 |        6262220 |
| wait/io/file/sql/FRM                         |       140221837119616 |         21 |       52320248 |         414069 |        2491440 |        5970995 |
| wait/io/file/sql/FRM                         |       140221837126480 |         21 |       52121509 |         399243 |        2481976 |        6055009 |
+----------------------------------------------+-----------------------+------------+----------------+----------------+----------------+----------------+
20 rows in set (0.00 sec)

Monitor&amp;gt; select * from EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME order by SUM_TIMER_WAIT desc limit 20;
+-----------+----------------------------------------------+------------+----------------+----------------+----------------+----------------+
| THREAD_ID | EVENT_NAME                                   | COUNT_STAR | SUM_TIMER_WAIT | MIN_TIMER_WAIT | AVG_TIMER_WAIT | MAX_TIMER_WAIT |
+-----------+----------------------------------------------+------------+----------------+----------------+----------------+----------------+
|         4 | wait/synch/cond/mysys/my_thread_var::suspend |          1 | 12977803964893 | 12977803964893 | 12977803964893 | 12977803964893 |
|         3 | wait/io/file/sql/FRM                         |         35 |    60054668620 |         332879 |     1715847674 |    44527633212 |
|         2 | wait/io/file/sql/FRM                         |        174 |      717013247 |         584921 |        4120765 |       13067354 |
|         0 | wait/io/file/sql/FRM                         |        396 |      513479801 |         384064 |        1296666 |        7093182 |
|         0 | wait/synch/mutex/mysys/THR_LOCK_malloc       |       1862 |      296733212 |         138023 |         159362 |        1797123 |
|         3 | wait/io/file/myisam/kfile                    |          9 |      223447588 |         999343 |       24827509 |      187585259 |
|         2 | wait/synch/mutex/mysys/THR_LOCK_malloc       |        763 |      193050758 |         198033 |         253015 |        4560760 |
|         0 | wait/synch/cond/sql/COND_thread_count        |          1 |      140672618 |      140672618 |      140672618 |      140672618 |
|         0 | wait/io/file/myisam/kfile                    |         67 |      139106710 |         459253 |        2076219 |        5604934 |
|         2 | wait/synch/mutex/sql/THD::LOCK_thd_data      |        191 |       96076716 |         206858 |         503019 |        1626271 |
|         0 | wait/io/file/myisam/dfile                    |         44 |       80252079 |         621280 |        1823910 |        3555416 |
|         0 | wait/io/file/sql/casetest                    |         10 |       75699438 |        2265201 |        7569943 |       22200876 |
|         1 | wait/io/file/sql/pid                         |          3 |       65458555 |        4716786 |       21819518 |       35012658 |
|         0 | wait/io/file/sql/ERRMSG                      |          5 |       58504102 |        1422237 |       11700820 |       23653118 |
|         2 | wait/io/file/sql/dbopt                       |          8 |       49073354 |        2748458 |        6134169 |       11395899 |
|         4 | wait/io/file/myisam/dfile                    |          3 |       45757625 |        3855819 |       15252541 |       32138179 |
|         2 | wait/synch/mutex/mysys/THR_LOCK_open         |        116 |       32695213 |         218860 |         281855 |         366061 |
|         0 | wait/synch/mutex/sql/LOCK_plugin             |        187 |       30413774 |         144024 |         162640 |         344881 |
|         0 | wait/io/file/sql/MYSQL_LOG                   |          4 |       29470558 |         732122 |        7367639 |       15266544 |
|         0 | wait/io/file/mysys/charset                   |          3 |       29210044 |        2685624 |        9736681 |       21207534 |
+-----------+----------------------------------------------+------------+----------------+----------------+----------------+----------------+
20 rows in set (0.01 sec) &lt;/pre&gt;

&lt;h2&gt;Harvesting the data for more&lt;/h2&gt;
&lt;p&gt; The performance schema currently exposes only a few aggregates.  Since the data is available as a SQL table (as opposed to a SHOW xxx result), regular SQL queries can be used, to build higher level score cards.  &lt;/p&gt;
&lt;pre&gt;
Monitor&amp;gt; select THREAD_ID, SUM(COUNT_STAR), SUM(SUM_TIMER_WAIT) from EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME group by THREAD_ID;
+-----------+-----------------+---------------------+
| THREAD_ID | SUM(COUNT_STAR) | SUM(SUM_TIMER_WAIT) |
+-----------+-----------------+---------------------+
|         0 |            3189 |          1501188274 |
|         1 |              12 |            69725619 |
|         2 |            2009 |          1539441825 |
|         3 |             206 |         60356070610 |
|         4 |              82 |      12977904034039 |
+-----------+-----------------+---------------------+
5 rows in set (0.01 sec) &lt;/pre&gt;
&lt;pre&gt;
Monitor&amp;gt; select SUM(COUNT_STAR), SUM(SUM_TIMER_WAIT) from EVENTS_WAITS_SUMMARY_BY_EVENT_NAME;
+-----------------+---------------------+
| SUM(COUNT_STAR) | SUM(SUM_TIMER_WAIT) |
+-----------------+---------------------+
|            5556 |      13041387778194 |
+-----------------+---------------------+
1 row in set (0.00 sec) &lt;/pre&gt;
&lt;h2&gt;The end&lt;/h2&gt;

&lt;p&gt; Interested readers are encouraged to try and play with the server to discover more, and look for more postings related to the MySQL performance schema.  &lt;/p&gt;
&lt;p&gt; -- Marc Alff &lt;/p&gt;</description><link>http://marcalff.blogspot.com/2010/01/performance-schema-overview.html</link><author>noreply@blogger.com (Marc Alff)</author><thr:total>0</thr:total></item></channel></rss>