Menu:
performance-schema-miscellaneous-tables:: Performance Schema Miscellaneous Tables
Tables in the 'performance_schema' database can be grouped as follows:
Setup tables. These tables are used to configure and display monitoring characteristics.
Current events tables. The note 'events_waits_current': performance-schema-events-waits-current-table. table contains the most recent event for each thread. Other similar tables contain current events at different levels of the event hierarchy: note 'events_stages_current': performance-schema-events-stages-current-table. for stage events, note 'events_statements_current': performance-schema-events-statements-current-table. for statement events, and note 'events_transactions_current': performance-schema-events-transactions-current-table. for transaction events.
History tables. These tables have the same structure as the current events tables, but contain more rows. For example, for wait events, note 'events_waits_history': performance-schema-events-waits-history-table. table contains the most recent 10 events per thread. note 'events_waits_history_long': performance-schema-events-waits-history-long-table. contains the most recent 10,000 events. Other similar tables exist for stage, statement, and transaction histories.
To change the sizes of the history tables, set the appropriate system variables at server startup. For example, to set the sizes of the wait event history tables, set 'performance_schema_events_waits_history_size' and 'performance_schema_events_waits_history_long_size'.
Summary tables. These tables contain information aggregated over groups of events, including those that have been discarded from the history tables.
Instance tables. These tables document what types of objects are instrumented. An instrumented object, when used by the server, produces an event. These tables provide event names and explanatory notes or status information.
Miscellaneous tables. These do not fall into any of the other table groups.
File: manual.info.tmp, Node: performance-schema-table-reference, Next: performance-schema-setup-tables, Prev: performance-schema-table-descriptions, Up: performance-schema-table-descriptions
The following table summarizes all available Performance Schema tables. For greater detail, see the individual table descriptions.
Performance Schema Tables
Table Name Description Deprecated
*note 'accounts': performance-schema-accounts-table.
Connection statistics per client account
*note 'cond_instances': performance-schema-cond-instances-table.
Synchronization object instances
*note 'events_stages_current': performance-schema-events-stages-current-table.
Current stage events
*note 'events_stages_history': performance-schema-events-stages-history-table.
Most recent stage events per thread
*note 'events_stages_history_long': performance-schema-events-stages-history-long-table.
Most recent stage events overall
*note 'events_stages_summary_by_account_by_event_name': performance-schema-stage-summary-tables.
Stage events per account and event name
*note 'events_stages_summary_by_host_by_event_name': performance-schema-stage-summary-tables.
Stage events per host name and event name
*note 'events_stages_summary_by_thread_by_event_name': performance-schema-stage-summary-tables.
Stage waits per thread and event name
*note 'events_stages_summary_by_user_by_event_name': performance-schema-stage-summary-tables.
Stage events per user name and event name
*note 'events_stages_summary_global_by_event_name': performance-schema-stage-summary-tables.
Stage waits per event name
*note 'events_statements_current': performance-schema-events-statements-current-table.
Current statement events
*note 'events_statements_history': performance-schema-events-statements-history-table.
Most recent statement events per thread
*note 'events_statements_history_long': performance-schema-events-statements-history-long-table.
Most recent statement events overall
*note 'events_statements_summary_by_account_by_event_name': performance-schema-statement-summary-tables.
Statement events per account and event name
*note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables.
Statement events per schema and digest value
*note 'events_statements_summary_by_host_by_event_name': performance-schema-statement-summary-tables.
Statement events per host name and event name
*note 'events_statements_summary_by_program': performance-schema-statement-summary-tables.
Statement events per stored program
*note 'events_statements_summary_by_thread_by_event_name': performance-schema-statement-summary-tables.
Statement events per thread and event name
*note 'events_statements_summary_by_user_by_event_name': performance-schema-statement-summary-tables.
Statement events per user name and event name
*note 'events_statements_summary_global_by_event_name': performance-schema-statement-summary-tables.
Statement events per event name
*note 'events_transactions_current': performance-schema-events-transactions-current-table.
Current transaction events
*note 'events_transactions_history': performance-schema-events-transactions-history-table.
Most recent transaction events per thread
*note 'events_transactions_history_long': performance-schema-events-transactions-history-long-table.
Most recent transaction events overall
*note 'events_transactions_summary_by_account_by_event_name': performance-schema-transaction-summary-tables.
Transaction events per account and event name
*note 'events_transactions_summary_by_host_by_event_name': performance-schema-transaction-summary-tables.
Transaction events per host name and event name
*note 'events_transactions_summary_by_thread_by_event_name': performance-schema-transaction-summary-tables.
Transaction events per thread and event name
*note 'events_transactions_summary_by_user_by_event_name': performance-schema-transaction-summary-tables.
Transaction events per user name and event name
*note 'events_transactions_summary_global_by_event_name': performance-schema-transaction-summary-tables.
Transaction events per event name
*note 'events_waits_current': performance-schema-events-waits-current-table.
Current wait events
*note 'events_waits_history': performance-schema-events-waits-history-table.
Most recent wait events per thread
*note 'events_waits_history_long': performance-schema-events-waits-history-long-table.
Most recent wait events overall
*note 'events_waits_summary_by_account_by_event_name': performance-schema-wait-summary-tables.
Wait events per account and event name
*note 'events_waits_summary_by_host_by_event_name': performance-schema-wait-summary-tables.
Wait events per host name and event name
*note 'events_waits_summary_by_instance': performance-schema-wait-summary-tables.
Wait events per instance
*note 'events_waits_summary_by_thread_by_event_name': performance-schema-wait-summary-tables.
Wait events per thread and event name
*note 'events_waits_summary_by_user_by_event_name': performance-schema-wait-summary-tables.
Wait events per user name and event name
*note 'events_waits_summary_global_by_event_name': performance-schema-wait-summary-tables.
Wait events per event name
*note 'file_instances': performance-schema-file-instances-table.
File instances
*note 'file_summary_by_event_name': performance-schema-file-summary-tables.
File events per event name
*note 'file_summary_by_instance': performance-schema-file-summary-tables.
File events per file instance
*note 'global_status': performance-schema-status-variable-tables.
Global status variables
*note 'global_variables': performance-schema-system-variable-tables.
Global system variables
*note 'host_cache': performance-schema-host-cache-table.
Information from internal host cache
*note 'hosts': performance-schema-hosts-table.
Connection statistics per client host name
*note 'memory_summary_by_account_by_event_name': performance-schema-memory-summary-tables.
Memory operations per account and event name
*note 'memory_summary_by_host_by_event_name': performance-schema-memory-summary-tables.
Memory operations per host and event name
*note 'memory_summary_by_thread_by_event_name': performance-schema-memory-summary-tables.
Memory operations per thread and event name
*note 'memory_summary_by_user_by_event_name': performance-schema-memory-summary-tables.
Memory operations per user and event name
*note 'memory_summary_global_by_event_name': performance-schema-memory-summary-tables.
Memory operations globally per event name
*note 'metadata_locks': performance-schema-metadata-locks-table.
Metadata locks and lock requests
*note 'mutex_instances': performance-schema-mutex-instances-table.
Mutex synchronization object instances
*note 'objects_summary_global_by_type': performance-schema-objects-summary-global-by-type-table.
Object summaries
*note 'performance_timers': performance-schema-performance-timers-table.
Which event timers are available
*note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table.
Prepared statement instances and statistics
*note 'replication_applier_configuration': performance-schema-replication-applier-configuration-table.
Configuration parameters for replication applier on replica
*note 'replication_applier_status': performance-schema-replication-applier-status-table.
Current status of replication applier on replica
*note 'replication_applier_status_by_coordinator': performance-schema-replication-applier-status-by-coordinator-table.
SQL or coordinator thread applier status
*note 'replication_applier_status_by_worker': performance-schema-replication-applier-status-by-worker-table.
Worker thread applier status
*note 'replication_connection_configuration': performance-schema-replication-connection-configuration-table.
Configuration parameters for connecting to source
*note 'replication_connection_status': performance-schema-replication-connection-status-table.
Current status of connection to source
*note 'replication_group_member_stats': performance-schema-replication-group-member-stats-table.
Replication group member statistics
*note 'replication_group_members': performance-schema-replication-group-members-table.
Replication group member network and status
*note 'rwlock_instances': performance-schema-rwlock-instances-table.
Lock synchronization object instances
*note 'session_account_connect_attrs': performance-schema-session-account-connect-attrs-table.
Connection attributes per for current session
*note 'session_connect_attrs': performance-schema-session-connect-attrs-table.
Connection attributes for all sessions
*note 'session_status': performance-schema-status-variable-tables.
Status variables for current session
*note 'session_variables': performance-schema-system-variable-tables.
System variables for current session
*note 'setup_actors': performance-schema-setup-actors-table.
How to initialize monitoring for new foreground threads
*note 'setup_consumers': performance-schema-setup-consumers-table.
Consumers for which event information can be stored
*note 'setup_instruments': performance-schema-setup-instruments-table.
Classes of instrumented objects for which events can be collected
*note 'setup_objects': performance-schema-setup-objects-table.
Which objects should be monitored
*note 'setup_timers': performance-schema-setup-timers-table.
Currently 5.7.21 selected event
timers
*note 'socket_instances': performance-schema-socket-instances-table.
Active connection instances
*note 'socket_summary_by_event_name': performance-schema-socket-summary-tables.
Socket waits and I/O per event name
*note 'socket_summary_by_instance': performance-schema-socket-summary-tables.
Socket waits and I/O per instance
*note 'status_by_account': performance-schema-status-variable-summary-tables.
Session status variables per account
*note 'status_by_host': performance-schema-status-variable-summary-tables.
Session status variables per host name
*note 'status_by_thread': performance-schema-status-variable-tables.
Session status variables per session
*note 'status_by_user': performance-schema-status-variable-summary-tables.
Session status variables per user name
*note 'table_handles': performance-schema-table-handles-table.
Table locks and lock requests
*note 'table_io_waits_summary_by_index_usage': performance-schema-table-io-waits-summary-by-index-usage-table.
Table I/O waits per index
*note 'table_io_waits_summary_by_table': performance-schema-table-io-waits-summary-by-table-table.
Table I/O waits per table
*note 'table_lock_waits_summary_by_table': performance-schema-table-lock-waits-summary-by-table-table.
Table lock waits per table
*note 'threads': performance-schema-threads-table.
Information about server threads
*note 'user_variables_by_thread': performance-schema-user-variable-tables.
User-defined variables per thread
*note 'users': performance-schema-users-table.
Connection statistics per client user name
*note 'variables_by_thread': performance-schema-system-variable-tables.
Session system variables per session
File: manual.info.tmp, Node: performance-schema-setup-tables, Next: performance-schema-instance-tables, Prev: performance-schema-table-reference, Up: performance-schema-table-descriptions
Menu:
performance-schema-setup-timers-table:: The setup_timers Table
The setup tables provide information about the current instrumentation and enable the monitoring configuration to be changed. For this reason, some columns in these tables can be changed if you have the 'UPDATE' privilege.
The use of tables rather than individual variables for setup information provides a high degree of flexibility in modifying Performance Schema configuration. For example, you can use a single statement with standard SQL syntax to make multiple simultaneous configuration changes.
These setup tables are available:
*note 'setup_actors': performance-schema-setup-actors-table.: How to initialize monitoring for new foreground threads
*note 'setup_consumers': performance-schema-setup-consumers-table.: The destinations to which event information can be sent and stored
*note 'setup_instruments': performance-schema-setup-instruments-table.: The classes of instrumented objects for which events can be collected
*note 'setup_objects': performance-schema-setup-objects-table.: Which objects should be monitored
*note 'setup_timers': performance-schema-setup-timers-table.: The current event timer
File: manual.info.tmp, Node: performance-schema-setup-actors-table, Next: performance-schema-setup-consumers-table, Prev: performance-schema-setup-tables, Up: performance-schema-setup-tables
25.12.2.1 The setup_actors Table ................................
The *note 'setup_actors': performance-schema-setup-actors-table. table contains information that determines whether to enable monitoring and historical event logging for new foreground server threads (threads associated with client connections). This table has a maximum size of 100 rows by default. To change the table size, modify the 'performance_schema_setup_actors_size' system variable at server startup.
For each new foreground thread, the Performance Schema matches the user and host for the thread against the rows of the note 'setup_actors': performance-schema-setup-actors-table. table. If a row from that table matches, its 'ENABLED' and 'HISTORY' column values are used to set the 'INSTRUMENTED' and 'HISTORY' columns, respectively, of the note 'threads': performance-schema-threads-table. table row for the thread. This enables instrumenting and historical event logging to be applied selectively per host, user, or account (user and host combination). If there is no match, the 'INSTRUMENTED' and 'HISTORY' columns for the thread are set to 'NO'.
For background threads, there is no associated user. 'INSTRUMENTED' and 'HISTORY' are 'YES' by default and *note 'setup_actors': performance-schema-setup-actors-table. is not consulted.
The initial contents of the *note 'setup_actors': performance-schema-setup-actors-table. table match any user and host combination, so monitoring and historical event collection are enabled by default for all foreground threads:
mysql> SELECT * FROM performance_schema.setup_actors;
+------+------+------+---------+---------+
| HOST | USER | ROLE | ENABLED | HISTORY |
+------+------+------+---------+---------+
| % | % | % | YES | YES |
+------+------+------+---------+---------+
For information about how to use the note 'setup_actors': performance-schema-setup-actors-table. table to affect event monitoring, see note performance-schema-thread-filtering::.
Modifications to the note 'setup_actors': performance-schema-setup-actors-table. table affect only foreground threads created subsequent to the modification, not existing threads. To affect existing threads, modify the 'INSTRUMENTED' and 'HISTORY' columns of note 'threads': performance-schema-threads-table. table rows.
The *note 'setup_actors': performance-schema-setup-actors-table. table has these columns:
'HOST'
The host name. This should be a literal name, or ''%'' to mean 'any host.'
'USER'
The user name. This should be a literal name, or ''%'' to mean 'any user.'
'ROLE'
Unused.
'ENABLED'
Whether to enable instrumentation for foreground threads matched by the row. The value is 'YES' or 'NO'.
'HISTORY'
Whether to log historical events for foreground threads matched by the row. The value is 'YES' or 'NO'.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'setup_actors': performance-schema-setup-actors-table. table. It removes the rows.
File: manual.info.tmp, Node: performance-schema-setup-consumers-table, Next: performance-schema-setup-instruments-table, Prev: performance-schema-setup-actors-table, Up: performance-schema-setup-tables
25.12.2.2 The setup_consumers Table ...................................
The *note 'setup_consumers': performance-schema-setup-consumers-table. table lists the types of consumers for which event information can be stored and which are enabled:
mysql> SELECT * FROM performance_schema.setup_consumers;
+----------------------------------+---------+
| NAME | ENABLED |
+----------------------------------+---------+
| events_stages_current | NO |
| events_stages_history | NO |
| events_stages_history_long | NO |
| events_statements_current | YES |
| events_statements_history | YES |
| events_statements_history_long | NO |
| events_transactions_current | NO |
| events_transactions_history | NO |
| events_transactions_history_long | NO |
| events_waits_current | NO |
| events_waits_history | NO |
| events_waits_history_long | NO |
| global_instrumentation | YES |
| thread_instrumentation | YES |
| statements_digest | YES |
+----------------------------------+---------+
The consumer settings in the note 'setup_consumers': performance-schema-setup-consumers-table. table form a hierarchy from higher levels to lower. For detailed information about the effect of enabling different consumers, see note performance-schema-consumer-filtering::.
Modifications to the *note 'setup_consumers': performance-schema-setup-consumers-table. table affect monitoring immediately.
The *note 'setup_consumers': performance-schema-setup-consumers-table. table has these columns:
'NAME'
The consumer name.
'ENABLED'
Whether the consumer is enabled. The value is 'YES' or 'NO'. This column can be modified. If you disable a consumer, the server does not spend time adding event information to it.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'setup_consumers': performance-schema-setup-consumers-table. table.
File: manual.info.tmp, Node: performance-schema-setup-instruments-table, Next: performance-schema-setup-objects-table, Prev: performance-schema-setup-consumers-table, Up: performance-schema-setup-tables
25.12.2.3 The setup_instruments Table .....................................
The *note 'setup_instruments': performance-schema-setup-instruments-table. table lists classes of instrumented objects for which events can be collected:
mysql> SELECT * FROM performance_schema.setup_instruments;
+---------------------------------------------------+---------+-------+
| NAME | ENABLED | TIMED |
+---------------------------------------------------+---------+-------+
...
| stage/sql/end | NO | NO |
| stage/sql/executing | NO | NO |
| stage/sql/init | NO | NO |
| stage/sql/insert | NO | NO |
...
| statement/sql/load | YES | YES |
| statement/sql/grant | YES | YES |
| statement/sql/check | YES | YES |
| statement/sql/flush | YES | YES |
...
| wait/synch/mutex/sql/LOCK_global_read_lock | YES | YES |
| wait/synch/mutex/sql/LOCK_global_system_variables | YES | YES |
| wait/synch/mutex/sql/LOCK_lock_db | YES | YES |
| wait/synch/mutex/sql/LOCK_manager | 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/io/file/sql/binlog | YES | YES |
| wait/io/file/sql/binlog_index | YES | YES |
| wait/io/file/sql/casetest | YES | YES |
| wait/io/file/sql/dbopt | YES | YES |
...
Each instrument added to the source code provides a row for the note 'setup_instruments': performance-schema-setup-instruments-table. table, even when the instrumented code is not executed. When an instrument is enabled and executed, instrumented instances are created, which are visible in the 'XXX_instances' tables, such as note 'file_instances': performance-schema-file-instances-table. or *note 'rwlock_instances': performance-schema-rwlock-instances-table.
Modifications to most *note 'setup_instruments': performance-schema-setup-instruments-table. rows affect monitoring immediately. For some instruments, modifications are effective only at server startup; changing them at runtime has no effect. This affects primarily mutexes, conditions, and rwlocks in the server, although there may be other instruments for which this is true.
For more information about the role of the note 'setup_instruments': performance-schema-setup-instruments-table. table in event filtering, see note performance-schema-pre-filtering::.
The *note 'setup_instruments': performance-schema-setup-instruments-table. table has these columns:
'NAME'
The instrument name. Instrument names may have multiple parts and form a hierarchy, as discussed in *note performance-schema-instrument-naming::. Events produced from execution of an instrument have an 'EVENT_NAME' value that is taken from the instrument 'NAME' value. (Events do not really have a 'name,' but this provides a way to associate events with instruments.)
'ENABLED'
Whether the instrument is enabled. The value is 'YES' or 'NO'. A disabled instrument produces no events. This column can be modified, although setting 'ENABLED' has no effect for instruments that have already been created.
'TIMED'
Whether the instrument is timed. The value is 'YES' or 'NO'. This column can be modified, although setting 'TIMED' has no effect for instruments that have already been created.
For memory instruments, the 'TIMED' column in *note 'setup_instruments': performance-schema-setup-instruments-table. is ignored because memory operations are not timed.
If an enabled instrument is not timed, the instrument code is enabled, but the timer is not. Events produced by the instrument have 'NULL' for the 'TIMER_START', 'TIMER_END', and 'TIMER_WAIT' timer values. This in turn causes those values to be ignored when calculating the sum, minimum, maximum, and average time values in summary tables.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'setup_instruments': performance-schema-setup-instruments-table. table.
File: manual.info.tmp, Node: performance-schema-setup-objects-table, Next: performance-schema-setup-timers-table, Prev: performance-schema-setup-instruments-table, Up: performance-schema-setup-tables
25.12.2.4 The setup_objects Table .................................
The *note 'setup_objects': performance-schema-setup-objects-table. table controls whether the Performance Schema monitors particular objects. This table has a maximum size of 100 rows by default. To change the table size, modify the 'performance_schema_setup_objects_size' system variable at server startup.
The initial *note 'setup_objects': performance-schema-setup-objects-table. contents look like this:
mysql> SELECT * FROM performance_schema.setup_objects;
+-------------+--------------------+-------------+---------+-------+
| OBJECT_TYPE | OBJECT_SCHEMA | OBJECT_NAME | ENABLED | TIMED |
+-------------+--------------------+-------------+---------+-------+
| EVENT | mysql | % | NO | NO |
| EVENT | performance_schema | % | NO | NO |
| EVENT | information_schema | % | NO | NO |
| EVENT | % | % | YES | YES |
| FUNCTION | mysql | % | NO | NO |
| FUNCTION | performance_schema | % | NO | NO |
| FUNCTION | information_schema | % | NO | NO |
| FUNCTION | % | % | YES | YES |
| PROCEDURE | mysql | % | NO | NO |
| PROCEDURE | performance_schema | % | NO | NO |
| PROCEDURE | information_schema | % | NO | NO |
| PROCEDURE | % | % | YES | YES |
| TABLE | mysql | % | NO | NO |
| TABLE | performance_schema | % | NO | NO |
| TABLE | information_schema | % | NO | NO |
| TABLE | % | % | YES | YES |
| TRIGGER | mysql | % | NO | NO |
| TRIGGER | performance_schema | % | NO | NO |
| TRIGGER | information_schema | % | NO | NO |
| TRIGGER | % | % | YES | YES |
+-------------+--------------------+-------------+---------+-------+
Modifications to the *note 'setup_objects': performance-schema-setup-objects-table. table affect object monitoring immediately.
For object types listed in *note 'setup_objects': performance-schema-setup-objects-table, the Performance Schema uses the table to how to monitor them. Object matching is based on the 'OBJECT_SCHEMA' and 'OBJECT_NAME' columns. Objects for which there is no match are not monitored.
The effect of the default object configuration is to instrument all tables except those in the 'mysql', 'INFORMATION_SCHEMA', and 'performance_schema' databases. (Tables in the 'INFORMATION_SCHEMA' database are not instrumented regardless of the contents of *note 'setup_objects': performance-schema-setup-objects-table.; the row for 'information_schema.%' simply makes this default explicit.)
When the Performance Schema checks for a match in note 'setup_objects': performance-schema-setup-objects-table, it tries to find more specific matches first. For example, with a table 'db1.t1', it looks for a match for ''db1'' and ''t1'', then for ''db1'' and ''%'', then for ''%'' and ''%''. The order in which matching occurs matters because different matching note 'setup_objects': performance-schema-setup-objects-table. rows can have different 'ENABLED' and 'TIMED' values.
Rows can be inserted into or deleted from *note 'setup_objects': performance-schema-setup-objects-table. by users with the 'INSERT' or 'DELETE' privilege on the table. For existing rows, only the 'ENABLED' and 'TIMED' columns can be modified, by users with the 'UPDATE' privilege on the table.
For more information about the role of the note 'setup_objects': performance-schema-setup-objects-table. table in event filtering, see note performance-schema-pre-filtering::.
The *note 'setup_objects': performance-schema-setup-objects-table. table has these columns:
'OBJECT_TYPE'
The type of object to instrument. The value is one of ''EVENT'' (Event Scheduler event), ''FUNCTION'' (stored function), ''PROCEDURE'' (stored procedure), ''TABLE'' (base table), or ''TRIGGER'' (trigger).
'TABLE' filtering affects table I/O events ('wait/io/table/sql/handler' instrument) and table lock events ('wait/lock/table/sql/handler' instrument).
'OBJECT_SCHEMA'
The schema that contains the object. This should be a literal name, or ''%'' to mean 'any schema.'
'OBJECT_NAME'
The name of the instrumented object. This should be a literal name, or ''%'' to mean 'any object.'
'ENABLED'
Whether events for the object are instrumented. The value is 'YES' or 'NO'. This column can be modified.
'TIMED'
Whether events for the object are timed. The value is 'YES' or 'NO'. This column can be modified.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'setup_objects': performance-schema-setup-objects-table. table. It removes the rows.
File: manual.info.tmp, Node: performance-schema-setup-timers-table, Prev: performance-schema-setup-objects-table, Up: performance-schema-setup-tables
25.12.2.5 The setup_timers Table ................................
The *note 'setup_timers': performance-schema-setup-timers-table. table shows the currently selected event timers:
mysql> SELECT * FROM performance_schema.setup_timers;
+-------------+-------------+
| NAME | TIMER_NAME |
+-------------+-------------+
| idle | MICROSECOND |
| wait | CYCLE |
| stage | NANOSECOND |
| statement | NANOSECOND |
| transaction | NANOSECOND |
+-------------+-------------+
Note:
As of MySQL 5.7.21, the Performance Schema note 'setup_timers': performance-schema-setup-timers-table. table is deprecated and is removed in MySQL 8.0, as is the 'TICKS' row in the note 'performance_timers': performance-schema-performance-timers-table. table.
The 'setup_timers.TIMER_NAME' value can be changed to select a different timer. The value can be any of the values in the 'performance_timers.TIMER_NAME' column. For an explanation of how event timing occurs, see *note performance-schema-timing::.
Modifications to the note 'setup_timers': performance-schema-setup-timers-table. table affect monitoring immediately. Events already in progress may use the original timer for the begin time and the new timer for the end time. To avoid unpredictable results after you make timer changes, use note 'TRUNCATE TABLE': truncate-table. to reset Performance Schema statistics.
The *note 'setup_timers': performance-schema-setup-timers-table. table has these columns:
'NAME'
The type of instrument the timer is used for.
'TIMER_NAME'
The timer that applies to the instrument type. This column can be modified.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'setup_timers': performance-schema-setup-timers-table. table.
File: manual.info.tmp, Node: performance-schema-instance-tables, Next: performance-schema-wait-tables, Prev: performance-schema-setup-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-socket-instances-table:: The socket_instances Table
Instance tables document what types of objects are instrumented. They provide event names and explanatory notes or status information:
*note 'cond_instances': performance-schema-cond-instances-table.: Condition synchronization object instances
*note 'file_instances': performance-schema-file-instances-table.: File instances
*note 'mutex_instances': performance-schema-mutex-instances-table.: Mutex synchronization object instances
*note 'rwlock_instances': performance-schema-rwlock-instances-table.: Lock synchronization object instances
*note 'socket_instances': performance-schema-socket-instances-table.: Active connection instances
These tables list instrumented synchronization objects, files, and connections. There are three types of synchronization objects: 'cond', 'mutex', and 'rwlock'. Each instance table has an 'EVENT_NAME' or 'NAME' column to indicate the instrument associated with each row. Instrument names may have multiple parts and form a hierarchy, as discussed in *note performance-schema-instrument-naming::.
The 'mutex_instances.LOCKED_BY_THREAD_ID' and 'rwlock_instances.WRITE_LOCKED_BY_THREAD_ID' columns are extremely important for investigating performance bottlenecks or deadlocks. For examples of how to use them for this purpose, see *note performance-schema-examples::
File: manual.info.tmp, Node: performance-schema-cond-instances-table, Next: performance-schema-file-instances-table, Prev: performance-schema-instance-tables, Up: performance-schema-instance-tables
25.12.3.1 The cond_instances Table ..................................
The *note 'cond_instances': performance-schema-cond-instances-table. table lists all the conditions seen by the Performance Schema while the server executes. A condition is a synchronization mechanism used in the code to signal that a specific event has happened, so that a thread waiting for this condition can resume work.
When a thread is waiting for something to happen, the condition name is an indication of what the thread is waiting for, but there is no immediate way to tell which other threads cause the condition to happen.
The *note 'cond_instances': performance-schema-cond-instances-table. table has these columns:
'NAME'
The instrument name associated with the condition.
'OBJECT_INSTANCE_BEGIN'
The address in memory of the instrumented condition.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'cond_instances': performance-schema-cond-instances-table. table.
File: manual.info.tmp, Node: performance-schema-file-instances-table, Next: performance-schema-mutex-instances-table, Prev: performance-schema-cond-instances-table, Up: performance-schema-instance-tables
25.12.3.2 The file_instances Table ..................................
The note 'file_instances': performance-schema-file-instances-table. table lists all the files seen by the Performance Schema when executing file I/O instrumentation. If a file on disk has never been opened, it is not in note 'file_instances': performance-schema-file-instances-table. When a file is deleted from the disk, it is also removed from the *note 'file_instances': performance-schema-file-instances-table. table.
The *note 'file_instances': performance-schema-file-instances-table. table has these columns:
'FILE_NAME'
The file name.
'EVENT_NAME'
The instrument name associated with the file.
'OPEN_COUNT'
The count of open handles on the file. If a file was opened and then closed, it was opened 1 time, but 'OPEN_COUNT' is 0. To list all the files currently opened by the server, use 'WHERE OPEN_COUNT > 0'.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'file_instances': performance-schema-file-instances-table. table.
File: manual.info.tmp, Node: performance-schema-mutex-instances-table, Next: performance-schema-rwlock-instances-table, Prev: performance-schema-file-instances-table, Up: performance-schema-instance-tables
25.12.3.3 The mutex_instances Table ...................................
The *note 'mutex_instances': performance-schema-mutex-instances-table. table lists all the mutexes seen by the Performance Schema while the server executes. A mutex is a synchronization mechanism used in the code to enforce that only one thread at a given time can have access to some common resource. The resource is said to be 'protected' by the mutex.
When two threads executing in the server (for example, two user sessions executing a query simultaneously) do need to access the same resource (a file, a buffer, or some piece of data), these two threads compete against each other, so that the first query to obtain a lock on the mutex causes the other query to wait until the first is done and unlocks the mutex.
The work performed while holding a mutex is said to be in a 'critical section,' and multiple queries do execute this critical section in a serialized way (one at a time), which is a potential bottleneck.
The *note 'mutex_instances': performance-schema-mutex-instances-table. table has these columns:
'NAME'
The instrument name associated with the mutex.
'OBJECT_INSTANCE_BEGIN'
The address in memory of the instrumented mutex.
'LOCKED_BY_THREAD_ID'
When a thread currently has a mutex locked, 'LOCKED_BY_THREAD_ID' is the 'THREAD_ID' of the locking thread, otherwise it is 'NULL'.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'mutex_instances': performance-schema-mutex-instances-table. table.
For every mutex instrumented in the code, the Performance Schema provides the following information.
The *note 'setup_instruments': performance-schema-setup-instruments-table. table lists the name of the instrumentation point, with the prefix 'wait/synch/mutex/'.
When some code creates a mutex, a row is added to the *note 'mutex_instances': performance-schema-mutex-instances-table. table. The 'OBJECT_INSTANCE_BEGIN' column is a property that uniquely identifies the mutex.
When a thread attempts to lock a mutex, the *note 'events_waits_current': performance-schema-events-waits-current-table. table shows a row for that thread, indicating that it is waiting on a mutex (in the 'EVENT_NAME' column), and indicating which mutex is waited on (in the 'OBJECT_INSTANCE_BEGIN' column).
When a thread succeeds in locking a mutex:
* *note 'events_waits_current':
performance-schema-events-waits-current-table. shows that the
wait on the mutex is completed (in the 'TIMER_END' and
'TIMER_WAIT' columns)
* The completed wait event is added to the *note
'events_waits_history':
performance-schema-events-waits-history-table. and *note
'events_waits_history_long':
performance-schema-events-waits-history-long-table. tables
* *note 'mutex_instances':
performance-schema-mutex-instances-table. shows that the mutex
is now owned by the thread (in the 'THREAD_ID' column).
When a thread unlocks a mutex, *note 'mutex_instances': performance-schema-mutex-instances-table. shows that the mutex now has no owner (the 'THREAD_ID' column is 'NULL').
When a mutex object is destroyed, the corresponding row is removed from *note 'mutex_instances': performance-schema-mutex-instances-table.
By performing queries on both of the following tables, a monitoring application or a DBA can detect bottlenecks or deadlocks between threads that involve mutexes:
*note 'events_waits_current': performance-schema-events-waits-current-table, to see what mutex a thread is waiting for
*note 'mutex_instances': performance-schema-mutex-instances-table, to see which other thread currently owns a mutex
File: manual.info.tmp, Node: performance-schema-rwlock-instances-table, Next: performance-schema-socket-instances-table, Prev: performance-schema-mutex-instances-table, Up: performance-schema-instance-tables
25.12.3.4 The rwlock_instances Table ....................................
The *note 'rwlock_instances': performance-schema-rwlock-instances-table. table lists all the rwlock (read write lock) instances seen by the Performance Schema while the server executes. An 'rwlock' is a synchronization mechanism used in the code to enforce that threads at a given time can have access to some common resource following certain rules. The resource is said to be 'protected' by the 'rwlock'. The access is either shared (many threads can have a read lock at the same time), exclusive (only one thread can have a write lock at a given time), or shared-exclusive (a thread can have a write lock while permitting inconsistent reads by other threads). Shared-exclusive access is otherwise known as an 'sxlock' and optimizes concurrency and improves scalability for read-write workloads.
Depending on how many threads are requesting a lock, and the nature of the locks requested, access can be either granted in shared mode, exclusive mode, shared-exclusive mode or not granted at all, waiting for other threads to finish first.
The *note 'rwlock_instances': performance-schema-rwlock-instances-table. table has these columns:
'NAME'
The instrument name associated with the lock.
'OBJECT_INSTANCE_BEGIN'
The address in memory of the instrumented lock.
'WRITE_LOCKED_BY_THREAD_ID'
When a thread currently has an 'rwlock' locked in exclusive (write) mode, 'WRITE_LOCKED_BY_THREAD_ID' is the 'THREAD_ID' of the locking thread, otherwise it is 'NULL'.
'READ_LOCKED_BY_COUNT'
When a thread currently has an 'rwlock' locked in shared (read) mode, 'READ_LOCKED_BY_COUNT' is incremented by 1. This is a counter only, so it cannot be used directly to find which thread holds a read lock, but it can be used to see whether there is a read contention on an 'rwlock', and see how many readers are currently active.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'rwlock_instances': performance-schema-rwlock-instances-table. table.
By performing queries on both of the following tables, a monitoring application or a DBA may detect some bottlenecks or deadlocks between threads that involve locks:
*note 'events_waits_current': performance-schema-events-waits-current-table, to see what 'rwlock' a thread is waiting for
*note 'rwlock_instances': performance-schema-rwlock-instances-table, to see which other thread currently owns an 'rwlock'
There is a limitation: The *note 'rwlock_instances': performance-schema-rwlock-instances-table. can be used only to identify the thread holding a write lock, but not the threads holding a read lock.
File: manual.info.tmp, Node: performance-schema-socket-instances-table, Prev: performance-schema-rwlock-instances-table, Up: performance-schema-instance-tables
25.12.3.5 The socket_instances Table ....................................
The note 'socket_instances': performance-schema-socket-instances-table. table provides a real-time snapshot of the active connections to the MySQL server. The table contains one row per TCP/IP or Unix socket file connection. Information available in this table provides a real-time snapshot of the active connections to the server. (Additional information is available in socket summary tables, including network activity such as socket operations and number of bytes transmitted and received; see note performance-schema-socket-summary-tables::).
mysql> SELECT * FROM performance_schema.socket_instances\G
*************************** 1. row ***************************
EVENT_NAME: wait/io/socket/sql/server_unix_socket
OBJECT_INSTANCE_BEGIN: 4316619408
THREAD_ID: 1
SOCKET_ID: 16
IP:
PORT: 0
STATE: ACTIVE
*************************** 2. row ***************************
EVENT_NAME: wait/io/socket/sql/client_connection
OBJECT_INSTANCE_BEGIN: 4316644608
THREAD_ID: 21
SOCKET_ID: 39
IP: 127.0.0.1
PORT: 55233
STATE: ACTIVE
*************************** 3. row ***************************
EVENT_NAME: wait/io/socket/sql/server_tcpip_socket
OBJECT_INSTANCE_BEGIN: 4316699040
THREAD_ID: 1
SOCKET_ID: 14
IP: 0.0.0.0
PORT: 50603
STATE: ACTIVE
Socket instruments have names of the form 'wait/io/socket/sql/SOCKET_TYPE' and are used like this:
The server has a listening socket for each network protocol that it supports. The instruments associated with listening sockets for TCP/IP or Unix socket file connections have a SOCKET_TYPE value of 'server_tcpip_socket' or 'server_unix_socket', respectively.
When a listening socket detects a connection, the server transfers the connection to a new socket managed by a separate thread. The instrument for the new connection thread has a SOCKET_TYPE value of 'client_connection'.
When a connection terminates, the row in *note 'socket_instances': performance-schema-socket-instances-table. corresponding to it is deleted.
The *note 'socket_instances': performance-schema-socket-instances-table. table has these columns:
'EVENT_NAME'
The name of the 'wait/io/socket/' instrument that produced the event. This is a 'NAME' value from the note 'setup_instruments': performance-schema-setup-instruments-table. table. Instrument names may have multiple parts and form a hierarchy, as discussed in *note performance-schema-instrument-naming::.
'OBJECT_INSTANCE_BEGIN'
This column uniquely identifies the socket. The value is the address of an object in memory.
'THREAD_ID'
The internal thread identifier assigned by the server. Each socket is managed by a single thread, so each socket can be mapped to a thread which can be mapped to a server process.
'SOCKET_ID'
The internal file handle assigned to the socket.
'IP'
The client IP address. The value may be either an IPv4 or IPv6 address, or blank to indicate a Unix socket file connection.
'PORT'
The TCP/IP port number, in the range from 0 to 65535.
'STATE'
The socket status, either 'IDLE' or 'ACTIVE'. Wait times for active sockets are tracked using the corresponding socket instrument. Wait times for idle sockets are tracked using the 'idle' instrument.
A socket is idle if it is waiting for a request from the client. When a socket becomes idle, the event row in note 'socket_instances': performance-schema-socket-instances-table. that is tracking the socket switches from a status of 'ACTIVE' to 'IDLE'. The 'EVENT_NAME' value remains 'wait/io/socket/', but timing for the instrument is suspended. Instead, an event is generated in the *note 'events_waits_current': performance-schema-events-waits-current-table. table with an 'EVENT_NAME' value of 'idle'.
When the next request is received, the 'idle' event terminates, the socket instance switches from 'IDLE' to 'ACTIVE', and timing of the socket instrument resumes.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'socket_instances': performance-schema-socket-instances-table. table.
The 'IP:PORT' column combination value identifies the connection. This combination value is used in the 'OBJECT_NAME' column of the 'events_waits_XXX' tables, to identify the connection from which socket events come:
For the Unix domain listener socket ('server_unix_socket'), the port is 0, and the IP is ''''.
For client connections via the Unix domain listener ('client_connection'), the port is 0, and the IP is ''''.
For the TCP/IP server listener socket ('server_tcpip_socket'), the port is always the master port (for example, 3306), and the IP is always '0.0.0.0'.
For client connections via the TCP/IP listener ('client_connection'), the port is whatever the server assigns, but never 0. The IP is the IP of the originating host ('127.0.0.1' or '::1' for the local host)
File: manual.info.tmp, Node: performance-schema-wait-tables, Next: performance-schema-stage-tables, Prev: performance-schema-instance-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-events-waits-history-long-table:: The events_waits_history_long Table
The Performance Schema instruments waits, which are events that take time. Within the event hierarchy, wait events nest within stage events, which nest within statement events, which nest within transaction events.
These tables store wait events:
*note 'events_waits_current': performance-schema-events-waits-current-table.: The current wait event for each thread.
*note 'events_waits_history': performance-schema-events-waits-history-table.: The most recent wait events that have ended per thread.
*note 'events_waits_history_long': performance-schema-events-waits-history-long-table.: The most recent wait events that have ended globally (across all threads).
The following sections describe the wait event tables. There are also summary tables that aggregate information about wait events; see *note performance-schema-wait-summary-tables::.
For more information about the relationship between the three wait event tables, see *note performance-schema-event-tables::.
Configuring Wait Event Collection
To control whether to collect wait events, set the state of the relevant instruments and consumers:
The *note 'setup_instruments': performance-schema-setup-instruments-table. table contains instruments with names that begin with 'wait'. Use these instruments to enable or disable collection of individual wait event classes.
The *note 'setup_consumers': performance-schema-setup-consumers-table. table contains consumer values with names corresponding to the current and historical wait event table names. Use these consumers to filter collection of wait events.
Some wait instruments are enabled by default; others are disabled. For example:
mysql> SELECT * FROM performance_schema.setup_instruments
WHERE NAME LIKE 'wait/io/file/innodb%';
+--------------------------------------+---------+-------+
| NAME | ENABLED | TIMED |
+--------------------------------------+---------+-------+
| wait/io/file/innodb/innodb_data_file | YES | YES |
| wait/io/file/innodb/innodb_log_file | YES | YES |
| wait/io/file/innodb/innodb_temp_file | YES | YES |
+--------------------------------------+---------+-------+
mysql> SELECT *
FROM performance_schema.setup_instruments WHERE
NAME LIKE 'wait/io/socket/%';
+----------------------------------------+---------+-------+
| NAME | ENABLED | TIMED |
+----------------------------------------+---------+-------+
| wait/io/socket/sql/server_tcpip_socket | NO | NO |
| wait/io/socket/sql/server_unix_socket | NO | NO |
| wait/io/socket/sql/client_connection | NO | NO |
+----------------------------------------+---------+-------+
The wait consumers are disabled by default:
mysql> SELECT *
FROM performance_schema.setup_consumers
WHERE NAME LIKE 'events_waits%';
+---------------------------+---------+
| NAME | ENABLED |
+---------------------------+---------+
| events_waits_current | NO |
| events_waits_history | NO |
| events_waits_history_long | NO |
+---------------------------+---------+
To control wait event collection at server startup, use lines like these in your 'my.cnf' file:
Enable:
[mysqld]
performance-schema-instrument='wait/%=ON'
performance-schema-consumer-events-waits-current=ON
performance-schema-consumer-events-waits-history=ON
performance-schema-consumer-events-waits-history-long=ON
Disable:
[mysqld]
performance-schema-instrument='wait/%=OFF'
performance-schema-consumer-events-waits-current=OFF
performance-schema-consumer-events-waits-history=OFF
performance-schema-consumer-events-waits-history-long=OFF
To control wait event collection at runtime, update the note 'setup_instruments': performance-schema-setup-instruments-table. and note 'setup_consumers': performance-schema-setup-consumers-table. tables:
Enable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES', TIMED = 'YES'
WHERE NAME LIKE 'wait/%';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'YES'
WHERE NAME LIKE 'events_waits%';
Disable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'NO', TIMED = 'NO'
WHERE NAME LIKE 'wait/%';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'NO'
WHERE NAME LIKE 'events_waits%';
To collect only specific wait events, enable only the corresponding wait instruments. To collect wait events only for specific wait event tables, enable the wait instruments but only the wait consumers corresponding to the desired tables.
The *note 'setup_timers': performance-schema-setup-timers-table. table contains a row with a 'NAME' value of 'wait' that indicates the unit for wait event timing. The default unit is 'CYCLE':
mysql> SELECT *
FROM performance_schema.setup_timers
WHERE NAME = 'wait';
+------+------------+
| NAME | TIMER_NAME |
+------+------------+
| wait | CYCLE |
+------+------------+
To change the timing unit, modify the 'TIMER_NAME' value:
UPDATE performance_schema.setup_timers
SET TIMER_NAME = 'NANOSECOND'
WHERE NAME = 'wait';
For additional information about configuring event collection, see note performance-schema-startup-configuration::, and note performance-schema-runtime-configuration::.
File: manual.info.tmp, Node: performance-schema-events-waits-current-table, Next: performance-schema-events-waits-history-table, Prev: performance-schema-wait-tables, Up: performance-schema-wait-tables
25.12.4.1 The events_waits_current Table ........................................
The *note 'events_waits_current': performance-schema-events-waits-current-table. table contains current wait events. The table stores one row per thread showing the current status of the thread's most recent monitored wait event, so there is no system variable for configuring the table size.
Of the tables that contain wait event rows, note 'events_waits_current': performance-schema-events-waits-current-table. is the most fundamental. Other tables that contain wait event rows are logically derived from the current events. For example, the note 'events_waits_history': performance-schema-events-waits-history-table. and *note 'events_waits_history_long': performance-schema-events-waits-history-long-table. tables are collections of the most recent wait events that have ended, up to a maximum number of rows per thread and globally across all threads, respectively.
For more information about the relationship between the three wait event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect wait events, see *note performance-schema-wait-tables::.
The *note 'events_waits_current': performance-schema-events-waits-current-table. table has these columns:
'THREAD_ID', 'EVENT_ID'
The thread associated with the event and the thread current event number when the event starts. The 'THREAD_ID' and 'EVENT_ID' values taken together uniquely identify the row. No two rows have the same pair of values.
'END_EVENT_ID'
This column is set to 'NULL' when the event starts and updated to the thread current event number when the event ends.
'EVENT_NAME'
The name of the instrument that produced the event. This is a 'NAME' value from the note 'setup_instruments': performance-schema-setup-instruments-table. table. Instrument names may have multiple parts and form a hierarchy, as discussed in note performance-schema-instrument-naming::.
'SOURCE'
The name of the source file containing the instrumented code that produced the event and the line number in the file at which the instrumentation occurs. This enables you to check the source to determine exactly what code is involved. For example, if a mutex or lock is being blocked, you can check the context in which this occurs.
'TIMER_START', 'TIMER_END', 'TIMER_WAIT'
Timing information for the event. The unit for these values is picoseconds (trillionths of a second). The 'TIMER_START' and 'TIMER_END' values indicate when event timing started and ended. 'TIMER_WAIT' is the event elapsed time (duration).
If an event has not finished, 'TIMER_END' is the current timer value and 'TIMER_WAIT' is the time elapsed so far ('TIMER_END' − 'TIMER_START').
If an event is produced from an instrument that has 'TIMED = NO', timing information is not collected, and 'TIMER_START', 'TIMER_END', and 'TIMER_WAIT' are all 'NULL'.
For discussion of picoseconds as the unit for event times and factors that affect time values, see *note performance-schema-timing::.
'SPINS'
For a mutex, the number of spin rounds. If the value is 'NULL', the code does not use spin rounds or spinning is not instrumented.
'OBJECT_SCHEMA', 'OBJECT_NAME', 'OBJECT_TYPE', 'OBJECT_INSTANCE_BEGIN'
These columns identify the object 'being acted on.' What that means depends on the object type.
For a synchronization object ('cond', 'mutex', 'rwlock'):
* 'OBJECT_SCHEMA', 'OBJECT_NAME', and 'OBJECT_TYPE' are 'NULL'.
* 'OBJECT_INSTANCE_BEGIN' is the address of the synchronization
object in memory.
For a file I/O object:
* 'OBJECT_SCHEMA' is 'NULL'.
* 'OBJECT_NAME' is the file name.
* 'OBJECT_TYPE' is 'FILE'.
* 'OBJECT_INSTANCE_BEGIN' is an address in memory.
For a socket object:
* 'OBJECT_NAME' is the 'IP:PORT' value for the socket.
* 'OBJECT_INSTANCE_BEGIN' is an address in memory.
For a table I/O object:
* 'OBJECT_SCHEMA' is the name of the schema that contains the
table.
* 'OBJECT_NAME' is the table name.
* 'OBJECT_TYPE' is 'TABLE' for a persistent base table or
'TEMPORARY TABLE' for a temporary table.
* 'OBJECT_INSTANCE_BEGIN' is an address in memory.
An 'OBJECT_INSTANCE_BEGIN' value itself has no meaning, except that different values indicate different objects. 'OBJECT_INSTANCE_BEGIN' can be used for debugging. For example, it can be used with 'GROUP BY OBJECT_INSTANCE_BEGIN' to see whether the load on 1,000 mutexes (that protect, say, 1,000 pages or blocks of data) is spread evenly or just hitting a few bottlenecks. This can help you correlate with other sources of information if you see the same object address in a log file or another debugging or performance tool.
'INDEX_NAME'
The name of the index used. 'PRIMARY' indicates the table primary index. 'NULL' means that no index was used.
'NESTING_EVENT_ID'
The 'EVENT_ID' value of the event within which this event is nested.
'NESTING_EVENT_TYPE'
The nesting event type. The value is 'TRANSACTION', 'STATEMENT', 'STAGE', or 'WAIT'.
'OPERATION'
The type of operation performed, such as 'lock', 'read', or 'write'.
'NUMBER_OF_BYTES'
The number of bytes read or written by the operation. For table I/O waits (events for the 'wait/io/table/sql/handler' instrument), 'NUMBER_OF_BYTES' indicates the number of rows. If the value is greater than 1, the event is for a batch I/O operation. The following discussion describes the difference between exclusively single-row reporting and reporting that reflects batch I/O.
MySQL executes joins using a nested-loop implementation. The job of the Performance Schema instrumentation is to provide row count and accumulated execution time per table in the join. Assume a join query of the following form that is executed using a table join order of 't1', 't2', 't3':
SELECT ... FROM t1 JOIN t2 ON ... JOIN t3 ON ...
Table 'fanout' is the increase or decrease in number of rows from adding a table during join processing. If the fanout for table 't3' is greater than 1, the majority of row-fetch operations are for that table. Suppose that the join accesses 10 rows from 't1', 20 rows from 't2' per row from 't1', and 30 rows from 't3' per row of table 't2'. With single-row reporting, the total number of instrumented operations is:
10 + (10 * 20) + (10 * 20 * 30) = 6210
A significant reduction in the number of instrumented operations is achievable by aggregating them per scan (that is, per unique combination of rows from 't1' and 't2'). With batch I/O reporting, the Performance Schema produces an event for each scan of the innermost table 't3' rather than for each row, and the number of instrumented row operations reduces to:
10 + (10 * 20) + (10 * 20) = 410
That is a reduction of 93%, illustrating how the batch-reporting strategy significantly reduces Performance Schema overhead for table I/O by reducing the number of reporting calls. The tradeoff is lesser accuracy for event timing. Rather than time for an individual row operation as in per-row reporting, timing for batch I/O includes time spent for operations such as join buffering, aggregation, and returning rows to the client.
For batch I/O reporting to occur, these conditions must be true:
* Query execution accesses the innermost table of a query block
(for a single-table query, that table counts as innermost)
* Query execution does not request a single row from the table
(so, for example, 'eq_ref' access prevents use of batch
reporting)
* Query execution does not evaluate a subquery containing table
access for the table
'FLAGS'
Reserved for future use.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_waits_current': performance-schema-events-waits-current-table. table. It removes the rows.
File: manual.info.tmp, Node: performance-schema-events-waits-history-table, Next: performance-schema-events-waits-history-long-table, Prev: performance-schema-events-waits-current-table, Up: performance-schema-wait-tables
25.12.4.2 The events_waits_history Table ........................................
The *note 'events_waits_history': performance-schema-events-waits-history-table. table contains the N most recent wait events that have ended per thread. Wait events are not added to the table until they have ended. When the table contains the maximum number of rows for a given thread, the oldest thread row is discarded when a new row for that thread is added. When a thread ends, all its rows are discarded.
The Performance Schema autosizes the value of N during server startup. To set the number of rows per thread explicitly, set the 'performance_schema_events_waits_history_size' system variable at server startup.
The note 'events_waits_history': performance-schema-events-waits-history-table. table has the same columns as note 'events_waits_current': performance-schema-events-waits-current-table. See *note performance-schema-events-waits-current-table::.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_waits_history': performance-schema-events-waits-history-table. table. It removes the rows.
For more information about the relationship between the three wait event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect wait events, see *note performance-schema-wait-tables::.
File: manual.info.tmp, Node: performance-schema-events-waits-history-long-table, Prev: performance-schema-events-waits-history-table, Up: performance-schema-wait-tables
25.12.4.3 The events_waits_history_long Table .............................................
The *note 'events_waits_history_long': performance-schema-events-waits-history-long-table. table contains N the most recent wait events that have ended globally, across all threads. Wait events are not added to the table until they have ended. When the table becomes full, the oldest row is discarded when a new row is added, regardless of which thread generated either row.
The Performance Schema autosizes the value of N during server startup. To set the table size explicitly, set the 'performance_schema_events_waits_history_long_size' system variable at server startup.
The note 'events_waits_history_long': performance-schema-events-waits-history-long-table. table has the same columns as note 'events_waits_current': performance-schema-events-waits-current-table. See *note performance-schema-events-waits-current-table::.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_waits_history_long': performance-schema-events-waits-history-long-table. table. It removes the rows.
For more information about the relationship between the three wait event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect wait events, see *note performance-schema-wait-tables::.
File: manual.info.tmp, Node: performance-schema-stage-tables, Next: performance-schema-statement-tables, Prev: performance-schema-wait-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-events-stages-history-long-table:: The events_stages_history_long Table
The Performance Schema instruments stages, which are steps during the statement-execution process, such as parsing a statement, opening a table, or performing a 'filesort' operation. Stages correspond to the thread states displayed by note 'SHOW PROCESSLIST': show-processlist. or that are visible in the Information Schema note 'PROCESSLIST': information-schema-processlist-table. table. Stages begin and end when state values change.
Within the event hierarchy, wait events nest within stage events, which nest within statement events, which nest within transaction events.
These tables store stage events:
*note 'events_stages_current': performance-schema-events-stages-current-table.: The current stage event for each thread.
*note 'events_stages_history': performance-schema-events-stages-history-table.: The most recent stage events that have ended per thread.
*note 'events_stages_history_long': performance-schema-events-stages-history-long-table.: The most recent stage events that have ended globally (across all threads).
The following sections describe the stage event tables. There are also summary tables that aggregate information about stage events; see *note performance-schema-stage-summary-tables::.
For more information about the relationship between the three stage event tables, see *note performance-schema-event-tables::.
*note stage-event-configuration::
*note stage-event-progress::
Configuring Stage Event Collection
To control whether to collect stage events, set the state of the relevant instruments and consumers:
The *note 'setup_instruments': performance-schema-setup-instruments-table. table contains instruments with names that begin with 'stage'. Use these instruments to enable or disable collection of individual stage event classes.
The *note 'setup_consumers': performance-schema-setup-consumers-table. table contains consumer values with names corresponding to the current and historical stage event table names. Use these consumers to filter collection of stage events.
Other than those instruments that provide statement progress information, the stage instruments are disabled by default. For example:
mysql> SELECT *
FROM performance_schema.setup_instruments
WHERE NAME RLIKE 'stage/sql/[a-c]';
+----------------------------------------------------+---------+-------+
| NAME | ENABLED | TIMED |
+----------------------------------------------------+---------+-------+
| stage/sql/After create | NO | NO |
| stage/sql/allocating local table | NO | NO |
| stage/sql/altering table | NO | NO |
| stage/sql/committing alter table to storage engine | NO | NO |
| stage/sql/Changing master | NO | NO |
| stage/sql/Checking master version | NO | NO |
| stage/sql/checking permissions | NO | NO |
| stage/sql/checking privileges on cached query | NO | NO |
| stage/sql/checking query cache for query | NO | NO |
| stage/sql/cleaning up | NO | NO |
| stage/sql/closing tables | NO | NO |
| stage/sql/Connecting to master | NO | NO |
| stage/sql/converting HEAP to MyISAM | NO | NO |
| stage/sql/Copying to group table | NO | NO |
| stage/sql/Copying to tmp table | NO | NO |
| stage/sql/copy to tmp table | NO | NO |
| stage/sql/Creating sort index | NO | NO |
| stage/sql/creating table | NO | NO |
| stage/sql/Creating tmp table | NO | NO |
+----------------------------------------------------+---------+-------+
Stage event instruments that provide statement progress information are enabled and timed by default:
mysql> SELECT *
FROM performance_schema.setup_instruments
WHERE ENABLED='YES' AND NAME LIKE "stage/%";
+------------------------------------------------------+---------+-------+
| NAME | ENABLED | TIMED |
+------------------------------------------------------+---------+-------+
| stage/sql/copy to tmp table | YES | YES |
| stage/innodb/alter table (end) | YES | YES |
| stage/innodb/alter table (flush) | YES | YES |
| stage/innodb/alter table (insert) | YES | YES |
| stage/innodb/alter table (log apply index) | YES | YES |
| stage/innodb/alter table (log apply table) | YES | YES |
| stage/innodb/alter table (merge sort) | YES | YES |
| stage/innodb/alter table (read PK and internal sort) | YES | YES |
| stage/innodb/buffer pool load | YES | YES |
+------------------------------------------------------+---------+-------+
The stage consumers are disabled by default:
mysql> SELECT *
FROM performance_schema.setup_consumers
WHERE NAME LIKE 'events_stages%';
+----------------------------+---------+
| NAME | ENABLED |
+----------------------------+---------+
| events_stages_current | NO |
| events_stages_history | NO |
| events_stages_history_long | NO |
+----------------------------+---------+
To control stage event collection at server startup, use lines like these in your 'my.cnf' file:
Enable:
[mysqld]
performance-schema-instrument='stage/%=ON'
performance-schema-consumer-events-stages-current=ON
performance-schema-consumer-events-stages-history=ON
performance-schema-consumer-events-stages-history-long=ON
Disable:
[mysqld]
performance-schema-instrument='stage/%=OFF'
performance-schema-consumer-events-stages-current=OFF
performance-schema-consumer-events-stages-history=OFF
performance-schema-consumer-events-stages-history-long=OFF
To control stage event collection at runtime, update the note 'setup_instruments': performance-schema-setup-instruments-table. and note 'setup_consumers': performance-schema-setup-consumers-table. tables:
Enable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES', TIMED = 'YES'
WHERE NAME LIKE 'stage/%';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'YES'
WHERE NAME LIKE 'events_stages%';
Disable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'NO', TIMED = 'NO'
WHERE NAME LIKE 'stage/%';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'NO'
WHERE NAME LIKE 'events_stages%';
To collect only specific stage events, enable only the corresponding stage instruments. To collect stage events only for specific stage event tables, enable the stage instruments but only the stage consumers corresponding to the desired tables.
The *note 'setup_timers': performance-schema-setup-timers-table. table contains a row with a 'NAME' value of 'stage' that indicates the unit for stage event timing. The default unit is 'NANOSECOND':
mysql> SELECT *
FROM performance_schema.setup_timers
WHERE NAME = 'stage';
+-------+------------+
| NAME | TIMER_NAME |
+-------+------------+
| stage | NANOSECOND |
+-------+------------+
To change the timing unit, modify the 'TIMER_NAME' value:
UPDATE performance_schema.setup_timers
SET TIMER_NAME = 'MICROSECOND'
WHERE NAME = 'stage';
For additional information about configuring event collection, see note performance-schema-startup-configuration::, and note performance-schema-runtime-configuration::.
Stage Event Progress Information
The Performance Schema stage event tables contain two columns that, taken together, provide a stage progress indicator for each row:
'WORK_COMPLETED': The number of work units completed for the stage
'WORK_ESTIMATED': The number of work units expected for the stage
Each column is 'NULL' if no progress information is provided for an instrument. Interpretation of the information, if it is available, depends entirely on the instrument implementation. The Performance Schema tables provide a container to store progress data, but make no assumptions about the semantics of the metric itself:
A 'work unit' is an integer metric that increases over time during execution, such as the number of bytes, rows, files, or tables processed. The definition of 'work unit' for a particular instrument is left to the instrumentation code providing the data.
The 'WORK_COMPLETED' value can increase one or many units at a time, depending on the instrumented code.
The 'WORK_ESTIMATED' value can change during the stage, depending on the instrumented code.
Instrumentation for a stage event progress indicator can implement any of the following behaviors:
No progress instrumentation
This is the most typical case, where no progress data is provided. The 'WORK_COMPLETED' and 'WORK_ESTIMATED' columns are both 'NULL'.
Unbounded progress instrumentation
Only the 'WORK_COMPLETED' column is meaningful. No data is provided for the 'WORK_ESTIMATED' column, which displays 0.
By querying the *note 'events_stages_current': performance-schema-events-stages-current-table. table for the monitored session, a monitoring application can report how much work has been performed so far, but cannot report whether the stage is near completion. Currently, no stages are instrumented like this.
Bounded progress instrumentation
The 'WORK_COMPLETED' and 'WORK_ESTIMATED' columns are both meaningful.
This type of progress indicator is appropriate for an operation with a defined completion criterion, such as the table-copy instrument described later. By querying the *note 'events_stages_current': performance-schema-events-stages-current-table. table for the monitored session, a monitoring application can report how much work has been performed so far, and can report the overall completion percentage for the stage, by computing the 'WORK_COMPLETED' / 'WORK_ESTIMATED' ratio.
The 'stage/sql/copy to tmp table' instrument illustrates how progress indicators work. During execution of an *note 'ALTER TABLE': alter-table. statement, the 'stage/sql/copy to tmp table' stage is used, and this stage can execute potentially for a long time, depending on the size of the data to copy.
The table-copy task has a defined termination (all rows copied), and the 'stage/sql/copy to tmp table' stage is instrumented to provided bounded progress information: The work unit used is number of rows copied, 'WORK_COMPLETED' and 'WORK_ESTIMATED' are both meaningful, and their ratio indicates task percentage complete.
To enable the instrument and the relevant consumers, execute these statements:
UPDATE performance_schema.setup_instruments
SET ENABLED='YES'
WHERE NAME='stage/sql/copy to tmp table';
UPDATE performance_schema.setup_consumers
SET ENABLED='YES'
WHERE NAME LIKE 'events_stages_%';
To see the progress of an ongoing note 'ALTER TABLE': alter-table. statement, select from the note 'events_stages_current': performance-schema-events-stages-current-table. table.
File: manual.info.tmp, Node: performance-schema-events-stages-current-table, Next: performance-schema-events-stages-history-table, Prev: performance-schema-stage-tables, Up: performance-schema-stage-tables
25.12.5.1 The events_stages_current Table .........................................
The *note 'events_stages_current': performance-schema-events-stages-current-table. table contains current stage events. The table stores one row per thread showing the current status of the thread's most recent monitored stage event, so there is no system variable for configuring the table size.
Of the tables that contain stage event rows, note 'events_stages_current': performance-schema-events-stages-current-table. is the most fundamental. Other tables that contain stage event rows are logically derived from the current events. For example, the note 'events_stages_history': performance-schema-events-stages-history-table. and *note 'events_stages_history_long': performance-schema-events-stages-history-long-table. tables are collections of the most recent stage events that have ended, up to a maximum number of rows per thread and globally across all threads, respectively.
For more information about the relationship between the three stage event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect stage events, see *note performance-schema-stage-tables::.
The *note 'events_stages_current': performance-schema-events-stages-current-table. table has these columns:
'THREAD_ID', 'EVENT_ID'
The thread associated with the event and the thread current event number when the event starts. The 'THREAD_ID' and 'EVENT_ID' values taken together uniquely identify the row. No two rows have the same pair of values.
'END_EVENT_ID'
This column is set to 'NULL' when the event starts and updated to the thread current event number when the event ends.
'EVENT_NAME'
The name of the instrument that produced the event. This is a 'NAME' value from the note 'setup_instruments': performance-schema-setup-instruments-table. table. Instrument names may have multiple parts and form a hierarchy, as discussed in note performance-schema-instrument-naming::.
'SOURCE'
The name of the source file containing the instrumented code that produced the event and the line number in the file at which the instrumentation occurs. This enables you to check the source to determine exactly what code is involved.
'TIMER_START', 'TIMER_END', 'TIMER_WAIT'
Timing information for the event. The unit for these values is picoseconds (trillionths of a second). The 'TIMER_START' and 'TIMER_END' values indicate when event timing started and ended. 'TIMER_WAIT' is the event elapsed time (duration).
If an event has not finished, 'TIMER_END' is the current timer value and 'TIMER_WAIT' is the time elapsed so far ('TIMER_END' − 'TIMER_START').
If an event is produced from an instrument that has 'TIMED = NO', timing information is not collected, and 'TIMER_START', 'TIMER_END', and 'TIMER_WAIT' are all 'NULL'.
For discussion of picoseconds as the unit for event times and factors that affect time values, see *note performance-schema-timing::.
'WORK_COMPLETED', 'WORK_ESTIMATED'
These columns provide stage progress information, for instruments that have been implemented to produce such information. 'WORK_COMPLETED' indicates how many work units have been completed for the stage, and 'WORK_ESTIMATED' indicates how many work units are expected for the stage. For more information, see *note stage-event-progress::.
'NESTING_EVENT_ID'
The 'EVENT_ID' value of the event within which this event is nested. The nesting event for a stage event is usually a statement event.
'NESTING_EVENT_TYPE'
The nesting event type. The value is 'TRANSACTION', 'STATEMENT', 'STAGE', or 'WAIT'.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_stages_current': performance-schema-events-stages-current-table. table. It removes the rows.
File: manual.info.tmp, Node: performance-schema-events-stages-history-table, Next: performance-schema-events-stages-history-long-table, Prev: performance-schema-events-stages-current-table, Up: performance-schema-stage-tables
25.12.5.2 The events_stages_history Table .........................................
The *note 'events_stages_history': performance-schema-events-stages-history-table. table contains the N most recent stage events that have ended per thread. Stage events are not added to the table until they have ended. When the table contains the maximum number of rows for a given thread, the oldest thread row is discarded when a new row for that thread is added. When a thread ends, all its rows are discarded.
The Performance Schema autosizes the value of N during server startup. To set the number of rows per thread explicitly, set the 'performance_schema_events_stages_history_size' system variable at server startup.
The note 'events_stages_history': performance-schema-events-stages-history-table. table has the same columns as note 'events_stages_current': performance-schema-events-stages-current-table. See *note performance-schema-events-stages-current-table::.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_stages_history': performance-schema-events-stages-history-table. table. It removes the rows.
For more information about the relationship between the three stage event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect stage events, see *note performance-schema-stage-tables::.
File: manual.info.tmp, Node: performance-schema-events-stages-history-long-table, Prev: performance-schema-events-stages-history-table, Up: performance-schema-stage-tables
25.12.5.3 The events_stages_history_long Table ..............................................
The *note 'events_stages_history_long': performance-schema-events-stages-history-long-table. table contains the N most recent stage events that have ended globally, across all threads. Stage events are not added to the table until they have ended. When the table becomes full, the oldest row is discarded when a new row is added, regardless of which thread generated either row.
The Performance Schema autosizes the value of N during server startup. To set the table size explicitly, set the 'performance_schema_events_stages_history_long_size' system variable at server startup.
The note 'events_stages_history_long': performance-schema-events-stages-history-long-table. table has the same columns as note 'events_stages_current': performance-schema-events-stages-current-table. See *note performance-schema-events-stages-current-table::.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_stages_history_long': performance-schema-events-stages-history-long-table. table. It removes the rows.
For more information about the relationship between the three stage event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect stage events, see *note performance-schema-stage-tables::.
File: manual.info.tmp, Node: performance-schema-statement-tables, Next: performance-schema-transaction-tables, Prev: performance-schema-stage-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-prepared-statements-instances-table:: The prepared_statements_instances Table
The Performance Schema instruments statement execution. Statement events occur at a high level of the event hierarchy. Within the event hierarchy, wait events nest within stage events, which nest within statement events, which nest within transaction events.
These tables store statement events:
*note 'events_statements_current': performance-schema-events-statements-current-table.: The current statement event for each thread.
*note 'events_statements_history': performance-schema-events-statements-history-table.: The most recent statement events that have ended per thread.
*note 'events_statements_history_long': performance-schema-events-statements-history-long-table.: The most recent statement events that have ended globally (across all threads).
*note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table.: Prepared statement instances and statistics
The following sections describe the statement event tables. There are also summary tables that aggregate information about statement events; see *note performance-schema-statement-summary-tables::.
For more information about the relationship between the three 'events_statements_XXX' event tables, see *note performance-schema-event-tables::.
*note performance-schema-statement-tables-configuration::
*note performance-schema-statement-tables-monitoring::
Configuring Statement Event Collection
To control whether to collect statement events, set the state of the relevant instruments and consumers:
The *note 'setup_instruments': performance-schema-setup-instruments-table. table contains instruments with names that begin with 'statement'. Use these instruments to enable or disable collection of individual statement event classes.
The *note 'setup_consumers': performance-schema-setup-consumers-table. table contains consumer values with names corresponding to the current and historical statement event table names, and the statement digest consumer. Use these consumers to filter collection of statement events and statement digesting.
The statement instruments are enabled by default, and the 'events_statements_current', 'events_statements_history', and 'statements_digest' statement consumers are enabled by default:
mysql> SELECT *
FROM performance_schema.setup_instruments
WHERE NAME LIKE 'statement/%';
+---------------------------------------------+---------+-------+
| NAME | ENABLED | TIMED |
+---------------------------------------------+---------+-------+
| statement/sql/select | YES | YES |
| statement/sql/create_table | YES | YES |
| statement/sql/create_index | YES | YES |
...
| statement/sp/stmt | YES | YES |
| statement/sp/set | YES | YES |
| statement/sp/set_trigger_field | YES | YES |
| statement/scheduler/event | YES | YES |
| statement/com/Sleep | YES | YES |
| statement/com/Quit | YES | YES |
| statement/com/Init DB | YES | YES |
...
| statement/abstract/Query | YES | YES |
| statement/abstract/new_packet | YES | YES |
| statement/abstract/relay_log | YES | YES |
+---------------------------------------------+---------+-------+
mysql> SELECT *
FROM performance_schema.setup_consumers
WHERE NAME LIKE '%statements%';
+--------------------------------+---------+
| NAME | ENABLED |
+--------------------------------+---------+
| events_statements_current | YES |
| events_statements_history | YES |
| events_statements_history_long | NO |
| statements_digest | YES |
+--------------------------------+---------+
To control statement event collection at server startup, use lines like these in your 'my.cnf' file:
Enable:
[mysqld]
performance-schema-instrument='statement/%=ON'
performance-schema-consumer-events-statements-current=ON
performance-schema-consumer-events-statements-history=ON
performance-schema-consumer-events-statements-history-long=ON
performance-schema-consumer-statements-digest=ON
Disable:
[mysqld]
performance-schema-instrument='statement/%=OFF'
performance-schema-consumer-events-statements-current=OFF
performance-schema-consumer-events-statements-history=OFF
performance-schema-consumer-events-statements-history-long=OFF
performance-schema-consumer-statements-digest=OFF
To control statement event collection at runtime, update the note 'setup_instruments': performance-schema-setup-instruments-table. and note 'setup_consumers': performance-schema-setup-consumers-table. tables:
Enable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES', TIMED = 'YES'
WHERE NAME LIKE 'statement/%';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'YES'
WHERE NAME LIKE '%statements%';
Disable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'NO', TIMED = 'NO'
WHERE NAME LIKE 'statement/%';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'NO'
WHERE NAME LIKE '%statements%';
To collect only specific statement events, enable only the corresponding statement instruments. To collect statement events only for specific statement event tables, enable the statement instruments but only the statement consumers corresponding to the desired tables.
The *note 'setup_timers': performance-schema-setup-timers-table. table contains a row with a 'NAME' value of 'statement' that indicates the unit for statement event timing. The default unit is 'NANOSECOND':
mysql> SELECT *
FROM performance_schema.setup_timers
WHERE NAME = 'statement';
+-----------+------------+
| NAME | TIMER_NAME |
+-----------+------------+
| statement | NANOSECOND |
+-----------+------------+
To change the timing unit, modify the 'TIMER_NAME' value:
UPDATE performance_schema.setup_timers
SET TIMER_NAME = 'MICROSECOND'
WHERE NAME = 'statement';
For additional information about configuring event collection, see note performance-schema-startup-configuration::, and note performance-schema-runtime-configuration::.
Statement Monitoring
Statement monitoring begins from the moment the server sees that activity is requested on a thread, to the moment when all activity has ceased. Typically, this means from the time the server gets the first packet from the client to the time the server has finished sending the response. Statements within stored programs are monitored like other statements.
When the Performance Schema instruments a request (server command or SQL statement), it uses instrument names that proceed in stages from more general (or 'abstract') to more specific until it arrives at a final instrument name.
Final instrument names correspond to server commands and SQL statements:
Server commands correspond to the 'COM_XXX codes' defined in the 'mysql_com.h' header file and processed in 'sql/sql_parse.cc'. Examples are 'COM_PING' and 'COM_QUIT'. Instruments for commands have names that begin with 'statement/com', such as 'statement/com/Ping' and 'statement/com/Quit'.
SQL statements are expressed as text, such as 'DELETE FROM t1' or 'SELECT * FROM t2'. Instruments for SQL statements have names that begin with 'statement/sql', such as 'statement/sql/delete' and 'statement/sql/select'.
Some final instrument names are specific to error handling:
'statement/com/Error' accounts for messages received by the server that are out of band. It can be used to detect commands sent by clients that the server does not understand. This may be helpful for purposes such as identifying clients that are misconfigured or using a version of MySQL more recent than that of the server, or clients that are attempting to attack the server.
'statement/sql/error' accounts for SQL statements that fail to parse. It can be used to detect malformed queries sent by clients. A query that fails to parse differs from a query that parses but fails due to an error during execution. For example, 'SELECT FROM' is malformed, and the 'statement/sql/error' instrument is used. By contrast, 'SELECT ' parses but fails with a 'No tables used' error. In this case, 'statement/sql/select' is used and the statement event contains information to indicate the nature of the error.
A request can be obtained from any of these sources:
As a command or statement request from a client, which sends the request as packets
As a statement string read from the relay log on a replica
As an event from the Event Scheduler
The details for a request are not initially known and the Performance Schema proceeds from abstract to specific instrument names in a sequence that depends on the source of the request.
For a request received from a client:
When the server detects a new packet at the socket level, a new statement is started with an abstract instrument name of 'statement/abstract/new_packet'.
When the server reads the packet number, it knows more about the type of request received, and the Performance Schema refines the instrument name. For example, if the request is a 'COM_PING' packet, the instrument name becomes 'statement/com/Ping' and that is the final name. If the request is a 'COM_QUERY' packet, it is known to correspond to an SQL statement but not the particular type of statement. In this case, the instrument changes from one abstract name to a more specific but still abstract name, 'statement/abstract/Query', and the request requires further classification.
If the request is a statement, the statement text is read and given to the parser. After parsing, the exact statement type is known. If the request is, for example, an *note 'INSERT': insert. statement, the Performance Schema refines the instrument name from 'statement/abstract/Query' to 'statement/sql/insert', which is the final name.
For a request read as a statement from the relay log on a replica:
Statements in the relay log are stored as text and are read as such. There is no network protocol, so the 'statement/abstract/new_packet' instrument is not used. Instead, the initial instrument is 'statement/abstract/relay_log'.
When the statement is parsed, the exact statement type is known. If the request is, for example, an *note 'INSERT': insert. statement, the Performance Schema refines the instrument name from 'statement/abstract/Query' to 'statement/sql/insert', which is the final name.
The preceding description applies only for statement-based replication. For row-based replication, table I/O done on the replica as it processes row changes can be instrumented, but row events in the relay log do not appear as discrete statements.
For a request received from the Event Scheduler:
The event execution is instrumented using the name 'statement/scheduler/event'. This is the final name.
Statements executed within the event body are instrumented using 'statement/sql/*' names, without use of any preceding abstract instrument. An event is a stored program, and stored programs are precompiled in memory before execution. Consequently, there is no parsing at runtime and the type of each statement is known by the time it executes.
Statements executed within the event body are child statements. For example, if an event executes an note 'INSERT': insert. statement, execution of the event itself is the parent, instrumented using 'statement/scheduler/event', and the note 'INSERT': insert. is the child, instrumented using 'statement/sql/insert'. The parent/child relationship holds between separate instrumented operations. This differs from the sequence of refinement that occurs within a single instrumented operation, from abstract to final instrument names.
For statistics to be collected for statements, it is not sufficient to enable only the final 'statement/sql/' instruments used for individual statement types. The abtract 'statement/abstract/' instruments must be enabled as well. This should not normally be an issue because all statement instruments are enabled by default. However, an application that enables or disables statement instruments selectively must take into account that disabling abstract instruments also disables statistics collection for the individual statement instruments. For example, to collect statistics for *note 'INSERT': insert. statements, 'statement/sql/insert' must be enabled, but also 'statement/abstract/new_packet' and 'statement/abstract/Query'. Similarly, for replicated statements to be instrumented, 'statement/abstract/relay_log' must be enabled.
No statistics are aggregated for abstract instruments such as 'statement/abstract/Query' because no statement is ever classified with an abstract instrument as the final statement name.
File: manual.info.tmp, Node: performance-schema-events-statements-current-table, Next: performance-schema-events-statements-history-table, Prev: performance-schema-statement-tables, Up: performance-schema-statement-tables
25.12.6.1 The events_statements_current Table .............................................
The *note 'events_statements_current': performance-schema-events-statements-current-table. table contains current statement events. The table stores one row per thread showing the current status of the thread's most recent monitored statement event, so there is no system variable for configuring the table size.
Of the tables that contain statement event rows, note 'events_statements_current': performance-schema-events-statements-current-table. is the most fundamental. Other tables that contain statement event rows are logically derived from the current events. For example, the note 'events_statements_history': performance-schema-events-statements-history-table. and *note 'events_statements_history_long': performance-schema-events-statements-history-long-table. tables are collections of the most recent statement events that have ended, up to a maximum number of rows per thread and globally across all threads, respectively.
For more information about the relationship between the three 'events_statements_XXX' event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect statement events, see *note performance-schema-statement-tables::.
The *note 'events_statements_current': performance-schema-events-statements-current-table. table has these columns:
'THREAD_ID', 'EVENT_ID'
The thread associated with the event and the thread current event number when the event starts. The 'THREAD_ID' and 'EVENT_ID' values taken together uniquely identify the row. No two rows have the same pair of values.
'END_EVENT_ID'
This column is set to 'NULL' when the event starts and updated to the thread current event number when the event ends.
'EVENT_NAME'
The name of the instrument from which the event was collected. This is a 'NAME' value from the note 'setup_instruments': performance-schema-setup-instruments-table. table. Instrument names may have multiple parts and form a hierarchy, as discussed in note performance-schema-instrument-naming::.
For SQL statements, the 'EVENT_NAME' value initially is 'statement/com/Query' until the statement is parsed, then changes to a more appropriate value, as described in *note performance-schema-statement-tables::.
'SOURCE'
The name of the source file containing the instrumented code that produced the event and the line number in the file at which the instrumentation occurs. This enables you to check the source to determine exactly what code is involved.
'TIMER_START', 'TIMER_END', 'TIMER_WAIT'
Timing information for the event. The unit for these values is picoseconds (trillionths of a second). The 'TIMER_START' and 'TIMER_END' values indicate when event timing started and ended. 'TIMER_WAIT' is the event elapsed time (duration).
If an event has not finished, 'TIMER_END' is the current timer value and 'TIMER_WAIT' is the time elapsed so far ('TIMER_END' − 'TIMER_START').
If an event is produced from an instrument that has 'TIMED = NO', timing information is not collected, and 'TIMER_START', 'TIMER_END', and 'TIMER_WAIT' are all 'NULL'.
For discussion of picoseconds as the unit for event times and factors that affect time values, see *note performance-schema-timing::.
'LOCK_TIME'
The time spent waiting for table locks. This value is computed in microseconds but normalized to picoseconds for easier comparison with other Performance Schema timers.
'SQL_TEXT'
The text of the SQL statement. For a command not associated with an SQL statement, the value is 'NULL'.
The maximum space available for statement display is 1024 bytes by default. To change this value, set the 'performance_schema_max_sql_text_length' system variable at server startup.
'DIGEST'
The statement digest MD5 value as a string of 32 hexadecimal characters, or 'NULL' if the 'statements_digest' consumer is 'no'. For more information about statement digesting, see *note performance-schema-statement-digests::.
'DIGEST_TEXT'
The normalized statement digest text, or 'NULL' if the 'statements_digest' consumer is 'no'. For more information about statement digesting, see *note performance-schema-statement-digests::.
The 'performance_schema_max_digest_length' system variable determines the maximum number of bytes available per session for digest value storage. However, the display length of statement digests may be longer than the available buffer size due to encoding of statement elements such as keywords and literal values in digest buffer. Consequently, values selected from the 'DIGEST_TEXT' column of statement event tables may appear to exceed the 'performance_schema_max_digest_length' value.
'CURRENT_SCHEMA'
The default database for the statement, 'NULL' if there is none.
'OBJECT_SCHEMA', 'OBJECT_NAME', 'OBJECT_TYPE'
For nested statements (stored programs), these columns contain information about the parent statement. Otherwise they are 'NULL'.
'OBJECT_INSTANCE_BEGIN'
This column identifies the statement. The value is the address of an object in memory.
'MYSQL_ERRNO'
The statement error number, from the statement diagnostics area.
'RETURNED_SQLSTATE'
The statement SQLSTATE value, from the statement diagnostics area.
'MESSAGE_TEXT'
The statement error message, from the statement diagnostics area.
'ERRORS'
Whether an error occurred for the statement. The value is 0 if the SQLSTATE value begins with '00' (completion) or '01' (warning). The value is 1 is the SQLSTATE value is anything else.
'WARNINGS'
The number of warnings, from the statement diagnostics area.
'ROWS_AFFECTED'
The number of rows affected by the statement. For a description of the meaning of 'affected,' see mysql_affected_rows() (https://dev.mysql.com/doc/c-api/5.7/en/mysql-affected-rows.html).
'ROWS_SENT'
The number of rows returned by the statement.
'ROWS_EXAMINED'
The number of rows examined by the server layer (not counting any processing internal to storage engines).
'CREATED_TMP_DISK_TABLES'
Like the 'Created_tmp_disk_tables' status variable, but specific to the statement.
'CREATED_TMP_TABLES'
Like the 'Created_tmp_tables' status variable, but specific to the statement.
'SELECT_FULL_JOIN'
Like the 'Select_full_join' status variable, but specific to the statement.
'SELECT_FULL_RANGE_JOIN'
Like the 'Select_full_range_join' status variable, but specific to the statement.
'SELECT_RANGE'
Like the 'Select_range' status variable, but specific to the statement.
'SELECT_RANGE_CHECK'
Like the 'Select_range_check' status variable, but specific to the statement.
'SELECT_SCAN'
Like the 'Select_scan' status variable, but specific to the statement.
'SORT_MERGE_PASSES'
Like the 'Sort_merge_passes' status variable, but specific to the statement.
'SORT_RANGE'
Like the 'Sort_range' status variable, but specific to the statement.
'SORT_ROWS'
Like the 'Sort_rows' status variable, but specific to the statement.
'SORT_SCAN'
Like the 'Sort_scan' status variable, but specific to the statement.
'NO_INDEX_USED'
1 if the statement performed a table scan without using an index, 0 otherwise.
'NO_GOOD_INDEX_USED'
1 if the server found no good index to use for the statement, 0 otherwise. For additional information, see the description of the 'Extra' column from 'EXPLAIN' output for the 'Range checked for each record' value in *note explain-output::.
'NESTING_EVENT_ID', 'NESTING_EVENT_TYPE', 'NESTING_EVENT_LEVEL'
These three columns are used with other columns to provide information as follows for top-level (unnested) statements and nested statements (executed within a stored program).
For top level statements:
OBJECT_TYPE = NULL
OBJECT_SCHEMA = NULL
OBJECT_NAME = NULL
NESTING_EVENT_ID = NULL
NESTING_EVENT_TYPE = NULL
NESTING_LEVEL = 0
For nested statements:
OBJECT_TYPE = the parent statement object type
OBJECT_SCHEMA = the parent statement object schema
OBJECT_NAME = the parent statement object name
NESTING_EVENT_ID = the parent statement EVENT_ID
NESTING_EVENT_TYPE = 'STATEMENT'
NESTING_LEVEL = the parent statement NESTING_LEVEL plus one
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_statements_current': performance-schema-events-statements-current-table. table. It removes the rows.
File: manual.info.tmp, Node: performance-schema-events-statements-history-table, Next: performance-schema-events-statements-history-long-table, Prev: performance-schema-events-statements-current-table, Up: performance-schema-statement-tables
25.12.6.2 The events_statements_history Table .............................................
The *note 'events_statements_history': performance-schema-events-statements-history-table. table contains the N most recent statement events that have ended per thread. Statement events are not added to the table until they have ended. When the table contains the maximum number of rows for a given thread, the oldest thread row is discarded when a new row for that thread is added. When a thread ends, all its rows are discarded.
The Performance Schema autosizes the value of N during server startup. To set the number of rows per thread explicitly, set the 'performance_schema_events_statements_history_size' system variable at server startup.
The note 'events_statements_history': performance-schema-events-statements-history-table. table has the same columns as note 'events_statements_current': performance-schema-events-statements-current-table. See *note performance-schema-events-statements-current-table::.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_statements_history': performance-schema-events-statements-history-table. table. It removes the rows.
For more information about the relationship between the three 'events_statements_XXX' event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect statement events, see *note performance-schema-statement-tables::.
File: manual.info.tmp, Node: performance-schema-events-statements-history-long-table, Next: performance-schema-prepared-statements-instances-table, Prev: performance-schema-events-statements-history-table, Up: performance-schema-statement-tables
25.12.6.3 The events_statements_history_long Table ..................................................
The *note 'events_statements_history_long': performance-schema-events-statements-history-long-table. table contains the N most recent statement events that have ended globally, across all threads. Statement events are not added to the table until they have ended. When the table becomes full, the oldest row is discarded when a new row is added, regardless of which thread generated either row.
The value of N is autosized at server startup. To set the table size explicitly, set the 'performance_schema_events_statements_history_long_size' system variable at server startup.
The note 'events_statements_history_long': performance-schema-events-statements-history-long-table. table has the same columns as note 'events_statements_current': performance-schema-events-statements-current-table. See *note performance-schema-events-statements-current-table::.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_statements_history_long': performance-schema-events-statements-history-long-table. table. It removes the rows.
For more information about the relationship between the three 'events_statements_XXX' event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect statement events, see *note performance-schema-statement-tables::.
File: manual.info.tmp, Node: performance-schema-prepared-statements-instances-table, Prev: performance-schema-events-statements-history-long-table, Up: performance-schema-statement-tables
25.12.6.4 The prepared_statements_instances Table .................................................
The Performance Schema provides instrumentation for prepared statements, for which there are two protocols:
The binary protocol. This is accessed through the MySQL C API and maps onto underlying server commands as shown in the following table.
C API Function Corresponding Server Command
'mysql_stmt_prepare()' 'COM_STMT_PREPARE' (https://dev.mysql.com/doc/c-api/5.7/en/mysql-stmt-prepare.html)
'mysql_stmt_execute()' 'COM_STMT_EXECUTE' (https://dev.mysql.com/doc/c-api/5.7/en/mysql-stmt-execute.html)
'mysql_stmt_close()' 'COM_STMT_CLOSE' (https://dev.mysql.com/doc/c-api/5.7/en/mysql-stmt-close.html)
The text protocol. This is accessed using SQL statements and maps onto underlying server commands as shown in the following table.
SQL Statement Corresponding Server Command
*note 'PREPARE': prepare. 'SQLCOM_PREPARE'
*note 'EXECUTE': execute. 'SQLCOM_EXECUTE'
note 'DEALLOCATE PREPARE': deallocate-prepare,'SQLCOM_DEALLOCATE PREPARE' note 'DROP PREPARE': deallocate-prepare.
Performance Schema prepared statement instrumentation covers both protocols. The following discussion refers to the server commands rather than the C API functions or SQL statements.
Information about prepared statements is available in the *note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table. table. This table enables inspection of prepared statements used in the server and provides aggregated statistics about them. To control the size of this table, set the 'performance_schema_max_prepared_statements_instances' system variable at server startup.
Collection of prepared statement information depends on the statement instruments shown in the following table. These instruments are enabled by default. To modify them, update the *note 'setup_instruments': performance-schema-setup-instruments-table. table.
Instrument Server Command
'statement/com/Prepare' 'COM_STMT_PREPARE'
'statement/com/Execute' 'COM_STMT_EXECUTE'
'statement/sql/prepare_sql' 'SQLCOM_PREPARE'
'statement/sql/execute_sql' 'SQLCOM_EXECUTE'
The Performance Schema manages the contents of the *note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table. table as follows:
Statement preparation
A 'COM_STMT_PREPARE' or 'SQLCOM_PREPARE' command creates a prepared statement in the server. If the statement is successfully instrumented, a new row is added to the *note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table. table. If the statement cannot be instrumented, 'Performance_schema_prepared_statements_lost' status variable is incremented.
Prepared statement execution
Execution of a 'COM_STMT_EXECUTE' or 'SQLCOM_PREPARE' command for an instrumented prepared statement instance updates the corresponding *note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table. table row.
Prepared statement deallocation
Execution of a 'COM_STMT_CLOSE' or 'SQLCOM_DEALLOCATE_PREPARE' command for an instrumented prepared statement instance removes the corresponding *note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table. table row. To avoid resource leaks, removal occurs even if the prepared statement instruments described previously are disabled.
The *note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table. table has these columns:
'OBJECT_INSTANCE_BEGIN'
The address in memory of the instrumented prepared statement.
'STATEMENT_ID'
The internal statement ID assigned by the server. The text and binary protocols both use statement IDs.
'STATEMENT_NAME'
For the binary protocol, this column is 'NULL'. For the text protocol, this column is the external statement name assigned by the user. For example, for the following SQL statement, the name of the prepared statement is 'stmt':
PREPARE stmt FROM 'SELECT 1';
'SQL_TEXT'
The prepared statement text, with '?' placeholder markers.
'OWNER_THREAD_ID', 'OWNER_EVENT_ID'
These columns indicate the event that created the prepared statement.
'OWNER_OBJECT_TYPE', 'OWNER_OBJECT_SCHEMA', 'OWNER_OBJECT_NAME'
For a prepared statement created by a client session, these columns are 'NULL'. For a prepared statement created by a stored program, these columns point to the stored program. A typical user error is forgetting to deallocate prepared statements. These columns can be used to find stored programs that leak prepared statements:
SELECT
OWNER_OBJECT_TYPE, OWNER_OBJECT_SCHEMA, OWNER_OBJECT_NAME,
STATEMENT_NAME, SQL_TEXT
FROM performance_schema.prepared_statements_instances
WHERE OWNER_OBJECT_TYPE IS NOT NULL;
'TIMER_PREPARE'
The time spent executing the statement preparation itself.
'COUNT_REPREPARE'
The number of times the statement was reprepared internally (see *note statement-caching::). Timing statistics for repreparation are not available because it is counted as part of statement execution, not as a separate operation.
'COUNT_EXECUTE', 'SUM_TIMER_EXECUTE', 'MIN_TIMER_EXECUTE', 'AVG_TIMER_EXECUTE', 'MAX_TIMER_EXECUTE'
Aggregated statistics for executions of the prepared statement.
'SUM_XXX'
The remaining 'SUM_XXX' columns are the same as for the statement summary tables (see *note performance-schema-statement-summary-tables::).
note 'TRUNCATE TABLE': truncate-table. resets the statistics columns of the note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table. table.
File: manual.info.tmp, Node: performance-schema-transaction-tables, Next: performance-schema-connection-tables, Prev: performance-schema-statement-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-events-transactions-history-long-table:: The events_transactions_history_long Table
The Performance Schema instruments transactions. Within the event hierarchy, wait events nest within stage events, which nest within statement events, which nest within transaction events.
These tables store transaction events:
*note 'events_transactions_current': performance-schema-events-transactions-current-table.: The current transaction event for each thread.
*note 'events_transactions_history': performance-schema-events-transactions-history-table.: The most recent transaction events that have ended per thread.
*note 'events_transactions_history_long': performance-schema-events-transactions-history-long-table.: The most recent transaction events that have ended globally (across all threads).
The following sections describe the transaction event tables. There are also summary tables that aggregate information about transaction events; see *note performance-schema-transaction-summary-tables::.
For more information about the relationship between the three transaction event tables, see *note performance-schema-event-tables::.
*note performance-schema-transaction-tables-configuration::
*note performance-schema-transaction-tables-transaction-boundaries::
*note performance-schema-transaction-tables-instrumentation::
*note performance-schema-transaction-tables-nested-events::
*note performance-schema-transaction-tables-stored-programs::
*note performance-schema-transaction-tables-savepoints::
*note performance-schema-transaction-tables-errors::
Configuring Transaction Event Collection
To control whether to collect transaction events, set the state of the relevant instruments and consumers:
The *note 'setup_instruments': performance-schema-setup-instruments-table. table contains an instrument named 'transaction'. Use this instrument to enable or disable collection of individual transaction event classes.
The *note 'setup_consumers': performance-schema-setup-consumers-table. table contains consumer values with names corresponding to the current and historical transaction event table names. Use these consumers to filter collection of transaction events.
The 'transaction' instrument and the transaction consumers are disabled by default:
mysql> SELECT *
FROM performance_schema.setup_instruments
WHERE NAME = 'transaction';
+-------------+---------+-------+
| NAME | ENABLED | TIMED |
+-------------+---------+-------+
| transaction | NO | NO |
+-------------+---------+-------+
mysql> SELECT *
FROM performance_schema.setup_consumers
WHERE NAME LIKE 'events_transactions%';
+----------------------------------+---------+
| NAME | ENABLED |
+----------------------------------+---------+
| events_transactions_current | NO |
| events_transactions_history | NO |
| events_transactions_history_long | NO |
+----------------------------------+---------+
To control transaction event collection at server startup, use lines like these in your 'my.cnf' file:
Enable:
[mysqld]
performance-schema-instrument='transaction=ON'
performance-schema-consumer-events-transactions-current=ON
performance-schema-consumer-events-transactions-history=ON
performance-schema-consumer-events-transactions-history-long=ON
Disable:
[mysqld]
performance-schema-instrument='transaction=OFF'
performance-schema-consumer-events-transactions-current=OFF
performance-schema-consumer-events-transactions-history=OFF
performance-schema-consumer-events-transactions-history-long=OFF
To control transaction event collection at runtime, update the note 'setup_instruments': performance-schema-setup-instruments-table. and note 'setup_consumers': performance-schema-setup-consumers-table. tables:
Enable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES', TIMED = 'YES'
WHERE NAME = 'transaction';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'YES'
WHERE NAME LIKE 'events_transactions%';
Disable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'NO', TIMED = 'NO'
WHERE NAME = 'transaction';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'NO'
WHERE NAME LIKE 'events_transactions%';
To collect transaction events only for specific transaction event tables, enable the 'transaction' instrument but only the transaction consumers corresponding to the desired tables.
The *note 'setup_timers': performance-schema-setup-timers-table. table contains a row with a 'NAME' value of 'transaction' that indicates the unit for transaction event timing. The default unit is 'NANOSECOND':
mysql> SELECT *
FROM performance_schema.setup_timers
WHERE NAME = 'transaction';
+-------------+------------+
| NAME | TIMER_NAME |
+-------------+------------+
| transaction | NANOSECOND |
+-------------+------------+
To change the timing unit, modify the 'TIMER_NAME' value:
UPDATE performance_schema.setup_timers
SET TIMER_NAME = 'MICROSECOND'
WHERE NAME = 'transaction';
For additional information about configuring event collection, see note performance-schema-startup-configuration::, and note performance-schema-runtime-configuration::.
Transaction Boundaries
In MySQL Server, transactions start explicitly with these statements:
START TRANSACTION | BEGIN | XA START | XA BEGIN
Transactions also start implicitly. For example, when the 'autocommit' system variable is enabled, the start of each statement starts a new transaction.
When 'autocommit' is disabled, the first statement following a committed transaction marks the start of a new transaction. Subsequent statements are part of the transaction until it is committed.
Transactions explicitly end with these statements:
COMMIT | ROLLBACK | XA COMMIT | XA ROLLBACK
Transactions also end implicitly, by execution of DDL statements, locking statements, and server administration statements.
In the following discussion, references to note 'START TRANSACTION': commit. also apply to note 'BEGIN': commit, note 'XA START': xa-statements, and note 'XA BEGIN': xa-statements. Similarly, references to note 'COMMIT': commit. and note 'ROLLBACK': commit. apply to note 'XA COMMIT': xa-statements. and note 'XA ROLLBACK': xa-statements, respectively.
The Performance Schema defines transaction boundaries similarly to that of the server. The start and end of a transaction event closely match the corresponding state transitions in the server:
For an explicitly started transaction, the transaction event starts during processing of the *note 'START TRANSACTION': commit. statement.
For an implicitly started transaction, the transaction event starts on the first statement that uses a transactional engine after the previous transaction has ended.
For any transaction, whether explicitly or implicitly ended, the transaction event ends when the server transitions out of the active transaction state during the processing of note 'COMMIT': commit. or note 'ROLLBACK': commit.
There are subtle implications to this approach:
Transaction events in the Performance Schema do not fully include the statement events associated with the corresponding note 'START TRANSACTION': commit, note 'COMMIT': commit, or *note 'ROLLBACK': commit. statements. There is a trivial amount of timing overlap between the transaction event and these statements.
Statements that work with nontransactional engines have no effect on the transaction state of the connection. For implicit transactions, the transaction event begins with the first statement that uses a transactional engine. This means that statements operating exclusively on nontransactional tables are ignored, even following *note 'START TRANSACTION': commit.
To illustrate, consider the following scenario:
1. SET autocommit = OFF;
2. CREATE TABLE t1 (a INT) ENGINE = InnoDB;
3. START TRANSACTION; -- Transaction 1 START
4. INSERT INTO t1 VALUES (1), (2), (3);
5. CREATE TABLE t2 (a INT) ENGINE = MyISAM; -- Transaction 1 COMMIT
-- (implicit; DDL forces commit)
6. INSERT INTO t2 VALUES (1), (2), (3); -- Update nontransactional table
7. UPDATE t2 SET a = a + 1; -- ... and again
8. INSERT INTO t1 VALUES (4), (5), (6); -- Write to transactional table
-- Transaction 2 START (implicit)
9. COMMIT; -- Transaction 2 COMMIT
From the perspective of the server, Transaction 1 ends when table 't2' is created. Transaction 2 does not start until a transactional table is accessed, despite the intervening updates to nontransactional tables.
From the perspective of the Performance Schema, Transaction 2 starts when the server transitions into an active transaction state. Statements 6 and 7 are not included within the boundaries of Transaction 2, which is consistent with how the server writes transactions to the binary log.
Transaction Instrumentation
Three attributes define transactions:
Access mode (read only, read write)
Isolation level ('SERIALIZABLE', 'REPEATABLE READ', and so forth)
Implicit ('autocommit' enabled) or explicit ('autocommit' disabled)
To reduce complexity of the transaction instrumentation and to ensure that the collected transaction data provides complete, meaningful results, all transactions are instrumented independently of access mode, isolation level, or autocommit mode.
To selectively examine transaction history, use the attribute columns in the transaction event tables: 'ACCESS_MODE', 'ISOLATION_LEVEL', and 'AUTOCOMMIT'.
The cost of transaction instrumentation can be reduced various ways, such as enabling or disabling transaction instrumentation according to user, account, host, or thread (client connection).
Transactions and Nested Events
The parent of a transaction event is the event that initiated the transaction. For an explicitly started transaction, this includes the note 'START TRANSACTION': commit. and note 'COMMIT AND CHAIN': commit. statements. For an implicitly started transaction, it is the first statement that uses a transactional engine after the previous transaction ends.
In general, a transaction is the top-level parent to all events initiated during the transaction, including statements that explicitly end the transaction such as note 'COMMIT': commit. and note 'ROLLBACK': commit. Exceptions are statements that implicitly end a transaction, such as DDL statements, in which case the current transaction must be committed before the new statement is executed.
Transactions and Stored Programs
Transactions and stored program events are related as follows:
Stored Procedures
Stored procedures operate independently of transactions. A stored procedure can be started within a transaction, and a transaction can be started or ended from within a stored procedure. If called from within a transaction, a stored procedure can execute statements that force a commit of the parent transaction and then start a new transaction.
If a stored procedure is started within a transaction, that transaction is the parent of the stored procedure event.
If a transaction is started by a stored procedure, the stored procedure is the parent of the transaction event.
Stored Functions
Stored functions are restricted from causing an explicit or implicit commit or rollback. Stored function events can reside within a parent transaction event.
Triggers
Triggers activate as part of a statement that accesses the table with which it is associated, so the parent of a trigger event is always the statement that activates it.
Triggers cannot issue statements that cause an explicit or implicit commit or rollback of a transaction.
Scheduled Events
The execution of the statements in the body of a scheduled event takes place in a new connection. Nesting of a scheduled event within a parent transaction is not applicable.
Transactions and Savepoints
Savepoint statements are recorded as separate statement events. Transaction events include separate counters for note 'SAVEPOINT': savepoint, note 'ROLLBACK TO SAVEPOINT': savepoint, and *note 'RELEASE SAVEPOINT': savepoint. statements issued during the transaction.
Transactions and Errors
Errors and warnings that occur within a transaction are recorded in statement events, but not in the corresponding transaction event. This includes transaction-specific errors and warnings, such as a rollback on a nontransactional table or GTID consistency errors.
File: manual.info.tmp, Node: performance-schema-events-transactions-current-table, Next: performance-schema-events-transactions-history-table, Prev: performance-schema-transaction-tables, Up: performance-schema-transaction-tables
25.12.7.1 The events_transactions_current Table ...............................................
The *note 'events_transactions_current': performance-schema-events-transactions-current-table. table contains current transaction events. The table stores one row per thread showing the current status of the thread's most recent monitored transaction event, so there is no system variable for configuring the table size. For example:
mysql> SELECT *
FROM performance_schema.events_transactions_current LIMIT 1\G
*************************** 1. row ***************************
THREAD_ID: 26
EVENT_ID: 7
END_EVENT_ID: NULL
EVENT_NAME: transaction
STATE: ACTIVE
TRX_ID: NULL
GTID: 3E11FA47-71CA-11E1-9E33-C80AA9429562:56
XID: NULL
XA_STATE: NULL
SOURCE: transaction.cc:150
TIMER_START: 420833537900000
TIMER_END: NULL
TIMER_WAIT: NULL
ACCESS_MODE: READ WRITE
ISOLATION_LEVEL: REPEATABLE READ
AUTOCOMMIT: NO
NUMBER_OF_SAVEPOINTS: 0
NUMBER_OF_ROLLBACK_TO_SAVEPOINT: 0
NUMBER_OF_RELEASE_SAVEPOINT: 0
OBJECT_INSTANCE_BEGIN: NULL
NESTING_EVENT_ID: 6
NESTING_EVENT_TYPE: STATEMENT
Of the tables that contain transaction event rows, note 'events_transactions_current': performance-schema-events-transactions-current-table. is the most fundamental. Other tables that contain transaction event rows are logically derived from the current events. For example, the note 'events_transactions_history': performance-schema-events-transactions-history-table. and *note 'events_transactions_history_long': performance-schema-events-transactions-history-long-table. tables are collections of the most recent transaction events that have ended, up to a maximum number of rows per thread and globally across all threads, respectively.
For more information about the relationship between the three transaction event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect transaction events, see *note performance-schema-transaction-tables::.
The *note 'events_transactions_current': performance-schema-events-transactions-current-table. table has these columns:
'THREAD_ID', 'EVENT_ID'
The thread associated with the event and the thread current event number when the event starts. The 'THREAD_ID' and 'EVENT_ID' values taken together uniquely identify the row. No two rows have the same pair of values.
'END_EVENT_ID'
This column is set to 'NULL' when the event starts and updated to the thread current event number when the event ends.
'EVENT_NAME'
The name of the instrument from which the event was collected. This is a 'NAME' value from the note 'setup_instruments': performance-schema-setup-instruments-table. table. Instrument names may have multiple parts and form a hierarchy, as discussed in note performance-schema-instrument-naming::.
'STATE'
The current transaction state. The value is 'ACTIVE' (after note 'START TRANSACTION': commit. or note 'BEGIN': commit.), 'COMMITTED' (after note 'COMMIT': commit.), or 'ROLLED BACK' (after note 'ROLLBACK': commit.).
'TRX_ID'
Unused.
'GTID'
The GTID column contains the value of 'gtid_next', which can be one of 'ANONYMOUS', 'AUTOMATIC', or a GTID using the format 'UUID:NUMBER'. For transactions that use 'gtid_next=AUTOMATIC', which is all normal client transactions, the GTID column changes when the transaction commits and the actual GTID is assigned. If 'gtid_mode' is either 'ON' or 'ON_PERMISSIVE', the GTID column changes to the transaction's GTID. If 'gtid_mode' is either 'OFF' or 'OFF_PERMISSIVE', the GTID column changes to 'ANONYMOUS'.
'XID_FORMAT_ID', 'XID_GTRID', and 'XID_BQUAL'
The elements of the XA transaction identifier. They have the format described in *note xa-statements::.
'XA_STATE'
The state of the XA transaction. The value is 'ACTIVE' (after note 'XA START': xa-statements.), 'IDLE' (after note 'XA END': xa-statements.), 'PREPARED' (after note 'XA PREPARE': xa-statements.), 'ROLLED BACK' (after note 'XA ROLLBACK': xa-statements.), or 'COMMITTED' (after *note 'XA COMMIT': xa-statements.).
On a replica, the same XA transaction can appear in the note 'events_transactions_current': performance-schema-events-transactions-current-table. table with different states on different threads. This is because immediately after the XA transaction is prepared, it is detached from the replication applier thread, and can be committed or rolled back by any thread on the replica. The note 'events_transactions_current': performance-schema-events-transactions-current-table. table displays the current status of the most recent monitored transaction event on the thread, and does not update this status when the thread is idle. So the XA transaction can still be displayed in the 'PREPARED' state for the original applier thread, after it has been processed by another thread. To positively identify XA transactions that are still in the 'PREPARED' state and need to be recovered, use the *note 'XA RECOVER': xa-statements. statement rather than the Performance Schema transaction tables.
'SOURCE'
The name of the source file containing the instrumented code that produced the event and the line number in the file at which the instrumentation occurs. This enables you to check the source to determine exactly what code is involved.
'TIMER_START', 'TIMER_END', 'TIMER_WAIT'
Timing information for the event. The unit for these values is picoseconds (trillionths of a second). The 'TIMER_START' and 'TIMER_END' values indicate when event timing started and ended. 'TIMER_WAIT' is the event elapsed time (duration).
If an event has not finished, 'TIMER_END' is the current timer value and 'TIMER_WAIT' is the time elapsed so far ('TIMER_END' − 'TIMER_START').
If an event is produced from an instrument that has 'TIMED = NO', timing information is not collected, and 'TIMER_START', 'TIMER_END', and 'TIMER_WAIT' are all 'NULL'.
For discussion of picoseconds as the unit for event times and factors that affect time values, see *note performance-schema-timing::.
'ACCESS_MODE'
The transaction access mode. The value is 'READ WRITE' or 'READ ONLY'.
'ISOLATION_LEVEL'
The transaction isolation level. The value is 'REPEATABLE READ', 'READ COMMITTED', 'READ UNCOMMITTED', or 'SERIALIZABLE'.
'AUTOCOMMIT'
Whether autcommit mode was enabled when the transaction started.
'NUMBER_OF_SAVEPOINTS', 'NUMBER_OF_ROLLBACK_TO_SAVEPOINT', 'NUMBER_OF_RELEASE_SAVEPOINT'
The number of note 'SAVEPOINT': savepoint, note 'ROLLBACK TO SAVEPOINT': savepoint, and *note 'RELEASE SAVEPOINT': savepoint. statements issued during the transaction.
'OBJECT_INSTANCE_BEGIN'
Unused.
'NESTING_EVENT_ID'
The 'EVENT_ID' value of the event within which this event is nested.
'NESTING_EVENT_TYPE'
The nesting event type. The value is 'TRANSACTION', 'STATEMENT', 'STAGE', or 'WAIT'. ('TRANSACTION' does not appear because transactions cannot be nested.)
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_transactions_current': performance-schema-events-transactions-current-table. table. It removes the rows.
File: manual.info.tmp, Node: performance-schema-events-transactions-history-table, Next: performance-schema-events-transactions-history-long-table, Prev: performance-schema-events-transactions-current-table, Up: performance-schema-transaction-tables
25.12.7.2 The events_transactions_history Table ...............................................
The *note 'events_transactions_history': performance-schema-events-transactions-history-table. table contains the N most recent transaction events that have ended per thread. Transaction events are not added to the table until they have ended. When the table contains the maximum number of rows for a given thread, the oldest thread row is discarded when a new row for that thread is added. When a thread ends, all its rows are discarded.
The Performance Schema autosizes the value of N during server startup. To set the number of rows per thread explicitly, set the 'performance_schema_events_transactions_history_size' system variable at server startup.
The note 'events_transactions_history': performance-schema-events-transactions-history-table. table has the same columns as note 'events_transactions_current': performance-schema-events-transactions-current-table. See *note performance-schema-events-transactions-current-table::.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_transactions_history': performance-schema-events-transactions-history-table. table. It removes the rows.
For more information about the relationship between the three transaction event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect transaction events, see *note performance-schema-transaction-tables::.
File: manual.info.tmp, Node: performance-schema-events-transactions-history-long-table, Prev: performance-schema-events-transactions-history-table, Up: performance-schema-transaction-tables
25.12.7.3 The events_transactions_history_long Table ....................................................
The *note 'events_transactions_history_long': performance-schema-events-transactions-history-long-table. table contains the N most recent transaction events that have ended globally, across all threads. Transaction events are not added to the table until they have ended. When the table becomes full, the oldest row is discarded when a new row is added, regardless of which thread generated either row.
The Performance Schema autosizes the value of N is autosized at server startup. To set the table size explicitly, set the 'performance_schema_events_transactions_history_long_size' system variable at server startup.
The note 'events_transactions_history_long': performance-schema-events-transactions-history-long-table. table has the same columns as note 'events_transactions_current': performance-schema-events-transactions-current-table. See *note performance-schema-events-transactions-current-table::.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'events_transactions_history_long': performance-schema-events-transactions-history-long-table. table. It removes the rows.
For more information about the relationship between the three transaction event tables, see *note performance-schema-event-tables::.
For information about configuring whether to collect transaction events, see *note performance-schema-transaction-tables::.
File: manual.info.tmp, Node: performance-schema-connection-tables, Next: performance-schema-connection-attribute-tables, Prev: performance-schema-transaction-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-users-table:: The users Table
When a client connects to the MySQL server, it does so under a particular user name and from a particular host. The Performance Schema provides statistics about these connections, tracking them per account (user and host combination) as well as separately per user name and host name, using these tables:
*note 'accounts': performance-schema-accounts-table.: Connection statistics per client account
*note 'hosts': performance-schema-hosts-table.: Connection statistics per client host name
*note 'users': performance-schema-users-table.: Connection statistics per client user name
The meaning of 'account' in the connection tables is similar to its meaning in the MySQL grant tables in the 'mysql' system database, in the sense that the term refers to a combination of user and host values. They differ in that, for grant tables, the host part of an account can be a pattern, whereas for Performance Schema tables, the host value is always a specific nonpattern host name.
Each connection table has 'CURRENT_CONNECTIONS' and 'TOTAL_CONNECTIONS' columns to track the current and total number of connections per 'tracking value' on which its statistics are based. The tables differ in what they use for the tracking value. The note 'accounts': performance-schema-accounts-table. table has 'USER' and 'HOST' columns to track connections per user and host combination. The note 'users': performance-schema-users-table. and *note 'hosts': performance-schema-hosts-table. tables have a 'USER' and 'HOST' column, respectively, to track connections per user name and host name.
The Performance Schema also counts internal threads and threads for user sessions that failed to authenticate, using rows with 'USER' and 'HOST' column values of 'NULL'.
Suppose that clients named 'user1' and 'user2' each connect one time from 'hosta' and 'hostb'. The Performance Schema tracks the connections as follows:
The *note 'accounts': performance-schema-accounts-table. table has four rows, for the 'user1'/'hosta', 'user1'/'hostb', 'user2'/'hosta', and 'user2'/'hostb' account values, each row counting one connection per account.
The *note 'hosts': performance-schema-hosts-table. table has two rows, for 'hosta' and 'hostb', each row counting two connections per host name.
The *note 'users': performance-schema-users-table. table has two rows, for 'user1' and 'user2', each row counting two connections per user name.
When a client connects, the Performance Schema determines which row in each connection table applies, using the tracking value appropriate to each table. If there is no such row, one is added. Then the Performance Schema increments by one the 'CURRENT_CONNECTIONS' and 'TOTAL_CONNECTIONS' columns in that row.
When a client disconnects, the Performance Schema decrements by one the 'CURRENT_CONNECTIONS' column in the row and leaves the 'TOTAL_CONNECTIONS' column unchanged.
*note 'TRUNCATE TABLE': truncate-table. is permitted for connection tables. It has these effects:
Rows are removed for accounts, hosts, or users that have no current connections (rows with 'CURRENT_CONNECTIONS = 0').
Nonremoved rows are reset to count only current connections: For rows with 'CURRENT_CONNECTIONS > 0', 'TOTAL_CONNECTIONS' is reset to 'CURRENT_CONNECTIONS'.
Summary tables that depend on the connection table are implicitly truncated, as described later in this section.
The Performance Schema maintains summary tables that aggregate connection statistics for various event types by account, host, or user. These tables have '_summary_by_account', '_summary_by_host', or '_summary_by_user' in the name. To identify them, use this query:
mysql> SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'performance_schema'
AND TABLE_NAME REGEXP '_summary_by_(account|host|user)'
ORDER BY TABLE_NAME;
+------------------------------------------------------+
| TABLE_NAME |
+------------------------------------------------------+
| events_stages_summary_by_account_by_event_name |
| events_stages_summary_by_host_by_event_name |
| events_stages_summary_by_user_by_event_name |
| events_statements_summary_by_account_by_event_name |
| events_statements_summary_by_host_by_event_name |
| events_statements_summary_by_user_by_event_name |
| events_transactions_summary_by_account_by_event_name |
| events_transactions_summary_by_host_by_event_name |
| events_transactions_summary_by_user_by_event_name |
| events_waits_summary_by_account_by_event_name |
| events_waits_summary_by_host_by_event_name |
| events_waits_summary_by_user_by_event_name |
| memory_summary_by_account_by_event_name |
| memory_summary_by_host_by_event_name |
| memory_summary_by_user_by_event_name |
+------------------------------------------------------+
For details about individual connection summary tables, consult the section that describes tables for the summarized event type:
Wait event summaries: *note performance-schema-wait-summary-tables::
Stage event summaries: *note performance-schema-stage-summary-tables::
Statement event summaries: *note performance-schema-statement-summary-tables::
Transaction event summaries: *note performance-schema-transaction-summary-tables::
Memory event summaries: *note performance-schema-memory-summary-tables::
*note 'TRUNCATE TABLE': truncate-table. is permitted for connection summary tables. It removes rows for accounts, hosts, or users with no connections, and resets the summary columns to zero for the remaining rows. In addition, each summary table that is aggregated by account, host, user, or thread is implicitly truncated by truncation of the connection table on which it depends. The following table describes the relationship between connection table truncation and implicitly truncated tables.
Implicit Effects of Connection Table Truncation
Truncated Connection Table Implicitly Truncated Summary Tables
'accounts' Tables with names containing '_summary_by_account', '_summary_by_thread'
'hosts' Tables with names containing '_summary_by_account', '_summary_by_host', '_summary_by_thread'
'users' Tables with names containing '_summary_by_account', '_summary_by_user', '_summary_by_thread'
Truncating a '_summary_global' summary table also implicitly truncates its corresponding connection and thread summary tables. For example, truncating *note 'events_waits_summary_global_by_event_name': performance-schema-wait-summary-tables. implicitly truncates the wait event summary tables that are aggregated by account, host, user, or thread.
File: manual.info.tmp, Node: performance-schema-accounts-table, Next: performance-schema-hosts-table, Prev: performance-schema-connection-tables, Up: performance-schema-connection-tables
25.12.8.1 The accounts Table ............................
The *note 'accounts': performance-schema-accounts-table. table contains a row for each account that has connected to the MySQL server. For each account, the table counts the current and total number of connections. The table size is autosized at server startup. To set the table size explicitly, set the 'performance_schema_accounts_size' system variable at server startup. To disable account statistics, set this variable to 0.
The note 'accounts': performance-schema-accounts-table. table has the following columns. For a description of how the Performance Schema maintains rows in this table, including the effect of note 'TRUNCATE TABLE': truncate-table, see *note performance-schema-connection-tables::.
'USER'
The client user name for the connection. This is 'NULL' for an internal thread, or for a user session that failed to authenticate.
'HOST'
The host from which the client connected. This is 'NULL' for an internal thread, or for a user session that failed to authenticate.
'CURRENT_CONNECTIONS'
The current number of connections for the account.
'TOTAL_CONNECTIONS'
The total number of connections for the account.
File: manual.info.tmp, Node: performance-schema-hosts-table, Next: performance-schema-users-table, Prev: performance-schema-accounts-table, Up: performance-schema-connection-tables
25.12.8.2 The hosts Table .........................
The *note 'hosts': performance-schema-hosts-table. table contains a row for each host from which clients have connected to the MySQL server. For each host name, the table counts the current and total number of connections. The table size is autosized at server startup. To set the table size explicitly, set the 'performance_schema_hosts_size' system variable at server startup. To disable host statistics, set this variable to 0.
The note 'hosts': performance-schema-hosts-table. table has the following columns. For a description of how the Performance Schema maintains rows in this table, including the effect of note 'TRUNCATE TABLE': truncate-table, see *note performance-schema-connection-tables::.
'HOST'
The host from which the client connected. This is 'NULL' for an internal thread, or for a user session that failed to authenticate.
'CURRENT_CONNECTIONS'
The current number of connections for the host.
'TOTAL_CONNECTIONS'
The total number of connections for the host.
File: manual.info.tmp, Node: performance-schema-users-table, Prev: performance-schema-hosts-table, Up: performance-schema-connection-tables
25.12.8.3 The users Table .........................
The *note 'users': performance-schema-users-table. table contains a row for each user who has connected to the MySQL server. For each user name, the table counts the current and total number of connections. The table size is autosized at server startup. To set the table size explicitly, set the 'performance_schema_users_size' system variable at server startup. To disable user statistics, set this variable to 0.
The note 'users': performance-schema-users-table. table has the following columns. For a description of how the Performance Schema maintains rows in this table, including the effect of note 'TRUNCATE TABLE': truncate-table, see *note performance-schema-connection-tables::.
'USER'
The client user name for the connection. This is 'NULL' for an internal thread, or for a user session that failed to authenticate.
'CURRENT_CONNECTIONS'
The current number of connections for the user.
'TOTAL_CONNECTIONS'
The total number of connections for the user.
File: manual.info.tmp, Node: performance-schema-connection-attribute-tables, Next: performance-schema-user-variable-tables, Prev: performance-schema-connection-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-session-connect-attrs-table:: The session_connect_attrs Table
Connection attributes are key-value pairs that application programs can pass to the server at connect time. For applications based on the C API implemented by the 'libmysqlclient' client library, the 'mysql_options()' (https://dev.mysql.com/doc/c-api/5.7/en/mysql-options.html) and 'mysql_options4()' (https://dev.mysql.com/doc/c-api/5.7/en/mysql-options4.html) functions define the connection attribute set. Other MySQL Connectors may provide their own attribute-definition methods.
These Performance Schema tables expose attribute information:
*note 'session_account_connect_attrs': performance-schema-session-account-connect-attrs-table.: Connection attributes for the current session, and other sessions associated with the session account
*note 'session_connect_attrs': performance-schema-session-connect-attrs-table.: Connection attributes for all sessions
Attribute names that begin with an underscore ('_') are reserved for internal use and should not be created by application programs. This convention permits new attributes to be introduced by MySQL without colliding with application attributes, and enables application programs to define their own attributes that do not collide with internal attributes.
*note performance-schema-connection-attributes-available::
*note performance-schema-connection-attribute-limits::
Available Connection Atrributes
The set of connection attributes visible within a given connection varies depending on factors such as your platform, MySQL Connector used to establish the connection, or client program.
The 'libmysqlclient' client library sets these attributes:
'_client_name': The client name ('libmysql' for the client library).
'_client_version': The client library version.
'_os': The operating system (for example, 'Linux', 'Win64').
'_pid': The client process ID.
'_platform': The machine platform (for example, 'x86_64').
'_thread': The client thread ID (Windows only).
Other MySQL Connectors may define their own connection attributes.
MySQL Connector/J defines these attributes:
'_client_license': The connector license type.
'_runtime_vendor': The Java runtime environment (JRE) vendor.
'_runtime_version': The Java runtime environment (JRE) version.
MySQL Connector/NET defines these attributes:
'_client_version': The client library version.
'_os': The operating system (for example, 'Linux', 'Win64').
'_pid': The client process ID.
'_platform': The machine platform (for example, 'x86_64').
'_program_name': The client name.
'_thread': The client thread ID (Windows only).
PHP defines attributes that depend on how it was compiled:
Compiled using 'libmysqlclient': The standard 'libmysqlclient' attributes, described previously.
Compiled using 'mysqlnd': Only the '_client_name' attribute, with a value of 'mysqlnd'.
Many MySQL client programs set a 'program_name' attribute with a value equal to the client name. For example, note 'mysqladmin': mysqladmin. and note 'mysqldump': mysqldump. set 'program_name' to 'mysqladmin' and 'mysqldump', respectively.
Some MySQL client programs define additional attributes:
*note 'mysqlbinlog': mysqlbinlog.:
* '_client_role': 'binary_log_listener'
Replica connections:
* 'program_name': 'mysqld'
* '_client_role': 'binary_log_listener'
* '_client_replication_channel_name': The channel name.
*note 'FEDERATED': federated-storage-engine. storage engine connections:
* 'program_name': 'mysqld'
* '_client_role': 'federated_storage'
Connection Atrribute Limits
There are limits on the amount of connection attribute data transmitted from client to server:
A fixed limit imposed by the client prior to connect time.
A fixed limit imposed by the server at connect time.
A configurable limit imposed by the Performance Schema at connect time.
For connections initiated using the C API, the 'libmysqlclient' library imposes a limit of 64KB on the aggregate size of connection attribute data on the client side: Calls to 'mysql_options()' (https://dev.mysql.com/doc/c-api/5.7/en/mysql-options.html) that cause this limit to be exceeded produce a 'CR_INVALID_PARAMETER_NO' (https://dev.mysql.com/doc/mysql-errors/5.7/en/client-error-reference.html#error_cr_invalid_parameter_no) error. Other MySQL Connectors may impose their own client-side limits on how much connection attribute data can be transmitted to the server.
On the server side, these size checks on connection attribute data occur:
The server imposes a limit of 64KB on the aggregate size of connection attribute data it can accept. If a client attempts to send more than 64KB of attribute data, the server rejects the connection.
For accepted connections, the Performance Schema checks aggregate attribute size against the value of the 'performance_schema_session_connect_attrs_size' system variable. If attribute size exceeds this value, these actions take place:
* The Performance Schema truncates the attribute data and
increments the 'Performance_schema_session_connect_attrs_lost'
status variable, which indicates the number of connections for
which attribute truncation occurred.
* The Performance Schema writes a message to the error log if
the 'log_error_verbosity' system variable is greater than 1:
[Warning] Connection attributes of length N were truncated
File: manual.info.tmp, Node: performance-schema-session-account-connect-attrs-table, Next: performance-schema-session-connect-attrs-table, Prev: performance-schema-connection-attribute-tables, Up: performance-schema-connection-attribute-tables
25.12.9.1 The session_account_connect_attrs Table .................................................
Application programs can provide key-value connection attributes to be passed to the server at connect time. For descriptions of common attributes, see *note performance-schema-connection-attribute-tables::.
The note 'session_account_connect_attrs': performance-schema-session-account-connect-attrs-table. table contains connection attributes only for the current session, and other sessions associated with the session account. To see connection attributes for all sessions, use the note 'session_connect_attrs': performance-schema-session-connect-attrs-table. table.
The *note 'session_account_connect_attrs': performance-schema-session-account-connect-attrs-table. table has these columns:
'PROCESSLIST_ID'
The connection identifier for the session.
'ATTR_NAME'
The attribute name.
'ATTR_VALUE'
The attribute value.
'ORDINAL_POSITION'
The order in which the attribute was added to the set of connection attributes.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'session_account_connect_attrs': performance-schema-session-account-connect-attrs-table. table.
File: manual.info.tmp, Node: performance-schema-session-connect-attrs-table, Prev: performance-schema-session-account-connect-attrs-table, Up: performance-schema-connection-attribute-tables
25.12.9.2 The session_connect_attrs Table .........................................
Application programs can provide key-value connection attributes to be passed to the server at connect time. For descriptions of common attributes, see *note performance-schema-connection-attribute-tables::.
The note 'session_connect_attrs': performance-schema-session-connect-attrs-table. table contains connection attributes for all sessions. To see connection attributes only for the current session, and other sessions associated with the session account, use the note 'session_account_connect_attrs': performance-schema-session-account-connect-attrs-table. table.
The *note 'session_connect_attrs': performance-schema-session-connect-attrs-table. table has these columns:
'PROCESSLIST_ID'
The connection identifier for the session.
'ATTR_NAME'
The attribute name.
'ATTR_VALUE'
The attribute value.
'ORDINAL_POSITION'
The order in which the attribute was added to the set of connection attributes.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'session_connect_attrs': performance-schema-session-connect-attrs-table. table.
File: manual.info.tmp, Node: performance-schema-user-variable-tables, Next: performance-schema-replication-tables, Prev: performance-schema-connection-attribute-tables, Up: performance-schema-table-descriptions
The Performance Schema provides a note 'user_variables_by_thread': performance-schema-user-variable-tables. table that exposes user-defined variables. These are variables defined within a specific session and include a '@' character preceding the name; see note user-variables::.
The *note 'user_variables_by_thread': performance-schema-user-variable-tables. table has these columns:
'THREAD_ID'
The thread identifier of the session in which the variable is defined.
'VARIABLE_NAME'
The variable name, without the leading '@' character.
'VARIABLE_VALUE'
The variable value.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'user_variables_by_thread': performance-schema-user-variable-tables. table.
File: manual.info.tmp, Node: performance-schema-replication-tables, Next: performance-schema-lock-tables, Prev: performance-schema-user-variable-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-replication-group-members-table:: The replication_group_members Table
The Performance Schema provides tables that expose replication information. This is similar to the information available from the *note 'SHOW SLAVE STATUS': show-slave-status. statement, but representation in table form is more accessible and has usability benefits:
note 'SHOW SLAVE STATUS': show-slave-status. output is useful for visual inspection, but not so much for programmatic use. By contrast, using the Performance Schema tables, information about replica status can be searched using general note 'SELECT': select. queries, including complex 'WHERE' conditions, joins, and so forth.
Query results can be saved in tables for further analysis, or assigned to variables and thus used in stored procedures.
The replication tables provide better diagnostic information. For multithreaded replica operation, *note 'SHOW SLAVE STATUS': show-slave-status. reports all coordinator and worker thread errors using the 'Last_SQL_Errno' and 'Last_SQL_Error' fields, so only the most recent of those errors is visible and information can be lost. The replication tables store errors on a per-thread basis without loss of information.
The last seen transaction is visible in the replication tables on a per-worker basis. This is information not avilable from *note 'SHOW SLAVE STATUS': show-slave-status.
Developers familiar with the Performance Schema interface can extend the replication tables to provide additional information by adding rows to the tables.
Replication Table Descriptions
The Performance Schema provides the following replication-related tables:
Tables that contain information about the connection of a replica to the replication source server:
* *note 'replication_connection_configuration':
performance-schema-replication-connection-configuration-table.:
Configuration parameters for connecting to the source
* *note 'replication_connection_status':
performance-schema-replication-connection-status-table.:
Current status of the connection to the source
Tables that contain general (not thread-specific) information about the transaction applier:
* *note 'replication_applier_configuration':
performance-schema-replication-applier-configuration-table.:
Configuration parameters for the transaction applier on the
replica.
* *note 'replication_applier_status':
performance-schema-replication-applier-status-table.: Current
status of the transaction applier on the replica.
Tables that contain information about specific threads responsible for applying transactions received from the source:
* *note 'replication_applier_status_by_coordinator':
performance-schema-replication-applier-status-by-coordinator-table.:
Status of the coordinator thread (empty unless the replica is
multithreaded).
* *note 'replication_applier_status_by_worker':
performance-schema-replication-applier-status-by-worker-table.:
Status of the applier thread or worker threads if the replica
is multithreaded.
Tables that contain information about replication group members:
* *note 'replication_group_members':
performance-schema-replication-group-members-table.: Provides
network and status information for group members.
* *note 'replication_group_member_stats':
performance-schema-replication-group-member-stats-table.:
Provides statistical information about group members and
transaction in which they participate.
The following sections describe each replication table in more detail, including the correspondence between the columns produced by *note 'SHOW SLAVE STATUS': show-slave-status. and the replication table columns in which the same information appears.
The remainder of this introduction to the replication tables describes how the Performance Schema populates them and which fields from *note 'SHOW SLAVE STATUS': show-slave-status. are not represented in the tables.
Replication Table Life Cycle
The Performance Schema populates the replication tables as follows:
Prior to execution of *note 'CHANGE MASTER TO': change-master-to, the tables are empty.
After *note 'CHANGE MASTER TO': change-master-to, the configuration parameters can be seen in the tables. At this time, there are no active replica threads, so the 'THREAD_ID' columns are 'NULL' and the 'SERVICE_STATE' columns have a value of 'OFF'.
After *note 'START SLAVE': start-slave, non-'NULL' 'THREAD_ID' values can be seen. Threads that are idle or active have a 'SERVICE_STATE' value of 'ON'. The thread that connects to the source has a value of 'CONNECTING' while it establishes the connection, and 'ON' thereafter as long as the connection lasts.
After *note 'STOP SLAVE': stop-slave, the 'THREAD_ID' columns become 'NULL' and the 'SERVICE_STATE' columns for threads that no longer exist have a value of 'OFF'.
The tables are preserved after *note 'STOP SLAVE': stop-slave. or threads dying due to an error.
The note 'replication_applier_status_by_worker': performance-schema-replication-applier-status-by-worker-table. table is nonempty only when the replica is operating in multithreaded mode. That is, if the 'slave_parallel_workers' system variable is greater than 0, this table is populated when note 'START SLAVE': start-slave. is executed, and the number of rows shows the number of workers.
**note 'SHOW SLAVE STATUS': show-slave-status. Information Not In the Replication Tables*
The information in the Performance Schema replication tables differs somewhat from the information available from note 'SHOW SLAVE STATUS': show-slave-status. because the tables are oriented toward use of global transaction identifiers (GTIDs), not file names and positions, and they represent server UUID values, not server ID values. Due to these differences, several note 'SHOW SLAVE STATUS': show-slave-status. columns are not preserved in the Performance Schema replication tables, or are represented a different way:
The following fields refer to file names and positions and are not preserved:
Master_Log_File
Read_Master_Log_Pos
Relay_Log_File
Relay_Log_Pos
Relay_Master_Log_File
Exec_Master_Log_Pos
Until_Condition
Until_Log_File
Until_Log_Pos
The 'Master_Info_File' field is not preserved. It refers to the 'master.info' file, which has been superseded by crash-safe tables.
The following fields are based on 'server_id', not 'server_uuid', and are not preserved:
Master_Server_Id
Replicate_Ignore_Server_Ids
The 'Skip_Counter' field is based on event counts, not GTIDs, and is not preserved.
These error fields are aliases for 'Last_SQL_Errno' and 'Last_SQL_Error', so they are not preserved:
Last_Errno
Last_Error
In the Performance Schema, this error information is available in the 'LAST_ERROR_NUMBER' and 'LAST_ERROR_MESSAGE' columns of the note 'replication_applier_status_by_worker': performance-schema-replication-applier-status-by-worker-table. table (and note 'replication_applier_status_by_coordinator': performance-schema-replication-applier-status-by-coordinator-table. if the replica is multithreaded). Those tables provide more specific per-thread error information than is available from 'Last_Errno' and 'Last_Error'.
Fields that provide information about command-line filtering options is not preserved:
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
The 'Slave_IO_State' and 'Slave_SQL_Running_State' fields are not preserved. If needed, these values can be obtained from the process list by using the 'THREAD_ID' column of the appropriate replication table and joining it with the 'ID' column in the 'INFORMATION_SCHEMA' *note 'PROCESSLIST': information-schema-processlist-table. table to select the 'STATE' column of the latter table.
The 'Executed_Gtid_Set' field can show a large set with a great deal of text. Instead, the Performance Schema tables show GTIDs of transactions that are currently being applied by the replica. Alternatively, the set of executed GTIDs can be obtained from the value of the 'gtid_executed' system variable.
The 'Seconds_Behind_Master' and 'Relay_Log_Space' fields are in to-be-decided status and are not preserved.
Status Variables Moved to Replication Tables
As of MySQL version 5.7.5, the following status variables (previously monitored using *note 'SHOW STATUS': show-status.) were moved to the Perfomance Schema replication tables:
'Slave_retried_transactions'
'Slave_last_heartbeat'
'Slave_received_heartbeats'
'Slave_heartbeat_period'
'Slave_running'
These status variables are now only relevant when a single replication channel is being used because they only report the status of the default replication channel. When multiple replication channels exist, use the Performance Schema replication tables described in this section, which report these variables for each existing replication channel.
Replication Channels
The first column of the replication Performance Schema tables is 'CHANNEL_NAME'. This enables the tables to be viewed per replication channel. In a non-multisource replication setup there is a single default replication channel. When you are using multiple replication channels on a replica, you can filter the tables per replication channel to monitor a specific replication channel. See note replication-channels:: and note replication-multi-source-monitoring:: for more information.
File: manual.info.tmp, Node: performance-schema-replication-connection-configuration-table, Next: performance-schema-replication-connection-status-table, Prev: performance-schema-replication-tables, Up: performance-schema-replication-tables
25.12.11.1 The replication_connection_configuration Table .........................................................
This table shows the configuration parameters used by the replica for connecting to the source. Parameters stored in the table can be changed at runtime with the *note 'CHANGE MASTER TO': change-master-to. statement, as indicated in the column descriptions.
Compared to the note 'replication_connection_status': performance-schema-replication-connection-status-table. table, note 'replication_connection_configuration': performance-schema-replication-connection-configuration-table. changes less frequently. It contains values that define how the replica connects to the source and that remain constant during the connection, whereas *note 'replication_connection_status': performance-schema-replication-connection-status-table. contains values that change during the connection.
The note 'replication_connection_configuration': performance-schema-replication-connection-configuration-table. table has the following columns. The column descriptions indicate the corresponding 'CHANGE MASTER TO' options from which the column values are taken, and the table given later in this section shows the correspondence between note 'replication_connection_configuration': performance-schema-replication-connection-configuration-table. columns and *note 'SHOW SLAVE STATUS': show-slave-status. columns.
'CHANNEL_NAME'
The replication channel which this row is displaying. There is always a default replication channel, and more replication channels can be added. See *note replication-channels:: for more information. ('CHANGE MASTER TO' option: 'FOR CHANNEL')
'HOST'
The replication source server that the replica is connected to. ('CHANGE MASTER TO' option: 'MASTER_HOST')
'PORT'
The port used to connect to the replication source server. ('CHANGE MASTER TO' option: 'MASTER_PORT')
'USER'
The user name of the account used to connect to the replication source server. ('CHANGE MASTER TO' option: 'MASTER_USER')
'NETWORK_INTERFACE'
The network interface that the replica is bound to, if any. ('CHANGE MASTER TO' option: 'MASTER_BIND')
'AUTO_POSITION'
1 if autopositioning is in use; otherwise 0. ('CHANGE MASTER TO' option: 'MASTER_AUTO_POSITION')
'SSL_ALLOWED', 'SSL_CA_FILE', 'SSL_CA_PATH', 'SSL_CERTIFICATE', 'SSL_CIPHER', 'SSL_KEY', 'SSL_VERIFY_SERVER_CERTIFICATE', 'SSL_CRL_FILE', 'SSL_CRL_PATH'
These columns show the SSL parameters used by the replica to connect to the replication source server, if any.
'SSL_ALLOWED' has these values:
* 'Yes' if an SSL connection to the source is permitted
* 'No' if an SSL connection to the source is not permitted
* 'Ignored' if an SSL connection is permitted but the replica
does not have SSL support enabled
'CHANGE MASTER TO' options for the other SSL columns: 'MASTER_SSL_CA', 'MASTER_SSL_CAPATH', 'MASTER_SSL_CERT', 'MASTER_SSL_CIPHER', 'MASTER_SSL_CRL', 'MASTER_SSL_CRLPATH', 'MASTER_SSL_KEY', 'MASTER_SSL_VERIFY_SERVER_CERT'.
'CONNECTION_RETRY_INTERVAL'
The number of seconds between connect retries. ('CHANGE MASTER TO' option: 'MASTER_CONNECT_RETRY')
'CONNECTION_RETRY_COUNT'
The number of times the replica can attempt to reconnect to the source in the event of a lost connection. ('CHANGE MASTER TO' option: 'MASTER_RETRY_COUNT')
'HEARTBEAT_INTERVAL'
The replication heartbeat interval on a replica, measured in seconds. ('CHANGE MASTER TO' option: 'MASTER_HEARTBEAT_PERIOD')
'TLS_VERSION'
The TLS version used on the source. For TLS version information, see *note encrypted-connection-protocols-ciphers::. ('CHANGE MASTER TO' option: 'MASTER_TLS_VERSION')
This column was added in MySQL 5.7.10.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'replication_connection_configuration': performance-schema-replication-connection-configuration-table. table.
The following table shows the correspondence between note 'replication_connection_configuration': performance-schema-replication-connection-configuration-table. columns and note 'SHOW SLAVE STATUS': show-slave-status. columns.
'replication_connection_configuration' 'SHOW SLAVE STATUS' Column Column
'CHANNEL_NAME' 'Channel_name'
'HOST' 'Master_Host'
'PORT' 'Master_Port'
'USER' 'Master_User'
'NETWORK_INTERFACE' 'Master_Bind'
'AUTO_POSITION' 'Auto_Position'
'SSL_ALLOWED' 'Master_SSL_Allowed'
'SSL_CA_FILE' 'Master_SSL_CA_File'
'SSL_CA_PATH' 'Master_SSL_CA_Path'
'SSL_CERTIFICATE' 'Master_SSL_Cert'
'SSL_CIPHER' 'Master_SSL_Cipher'
'SSL_KEY' 'Master_SSL_Key'
'SSL_VERIFY_SERVER_CERTIFICATE' 'Master_SSL_Verify_Server_Cert'
'SSL_CRL_FILE' 'Master_SSL_Crl'
'SSL_CRL_PATH' 'Master_SSL_Crlpath'
'CONNECTION_RETRY_INTERVAL' 'Connect_Retry'
'CONNECTION_RETRY_COUNT' 'Master_Retry_Count'
'HEARTBEAT_INTERVAL' None
'TLS_VERSION' 'Master_TLS_Version'
File: manual.info.tmp, Node: performance-schema-replication-connection-status-table, Next: performance-schema-replication-applier-configuration-table, Prev: performance-schema-replication-connection-configuration-table, Up: performance-schema-replication-tables
25.12.11.2 The replication_connection_status Table ..................................................
This table shows the current status of the replication I/O thread that handles the replica's connection to the source.
Compared to the note 'replication_connection_configuration': performance-schema-replication-connection-configuration-table. table, note 'replication_connection_status': performance-schema-replication-connection-status-table. changes more frequently. It contains values that change during the connection, whereas *note 'replication_connection_configuration': performance-schema-replication-connection-configuration-table. contains values which define how the replica connects to the source and that remain constant during the connection.
The *note 'replication_connection_status': performance-schema-replication-connection-status-table. table has these columns:
'CHANNEL_NAME'
The replication channel which this row is displaying. There is always a default replication channel, and more replication channels can be added. See *note replication-channels:: for more information.
'GROUP_NAME'
If this server is a member of a group, shows the name of the group the server belongs to.
'SOURCE_UUID'
The 'server_uuid' value from the source.
'THREAD_ID'
The I/O thread ID.
'SERVICE_STATE'
'ON' (thread exists and is active or idle), 'OFF' (thread no longer exists), or 'CONNECTING' (thread exists and is connecting to the source).
'RECEIVED_TRANSACTION_SET'
The set of global transaction IDs (GTIDs) corresponding to all transactions received by this replica. Empty if GTIDs are not in use. See *note replication-gtids-concepts-gtid-sets:: for more information.
'LAST_ERROR_NUMBER', 'LAST_ERROR_MESSAGE'
The error number and error message of the most recent error that caused the I/O thread to stop. An error number of 0 and message of the empty string mean 'no error.' If the 'LAST_ERROR_MESSAGE' value is not empty, the error values also appear in the replica's error log.
Issuing note 'RESET MASTER': reset-master. or note 'RESET SLAVE': reset-slave. resets the values shown in these columns.
'LAST_ERROR_TIMESTAMP'
A timestamp in YYMMDD HH:MM:SS format that shows when the most recent I/O error took place.
'LAST_HEARTBEAT_TIMESTAMP'
A timestamp in YYMMDD HH:MM:SS format that shows when the most recent heartbeat signal was received by a replica.
'COUNT_RECEIVED_HEARTBEATS'
The total number of heartbeat signals that a replica received since the last time it was restarted or reset, or a 'CHANGE MASTER TO' statement was issued.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'replication_connection_status': performance-schema-replication-connection-status-table. table.
The following table shows the correspondence between note 'replication_connection_status': performance-schema-replication-connection-status-table. columns and note 'SHOW SLAVE STATUS': show-slave-status. columns.
'replication_connection_status' Column 'SHOW SLAVE STATUS' Column
'SOURCE_UUID' 'Master_UUID'
'THREAD_ID' None
'SERVICE_STATE' 'Slave_IO_Running'
'RECEIVED_TRANSACTION_SET' 'Retrieved_Gtid_Set'
'LAST_ERROR_NUMBER' 'Last_IO_Errno'
'LAST_ERROR_MESSAGE' 'Last_IO_Error'
'LAST_ERROR_TIMESTAMP' 'Last_IO_Error_Timestamp'
File: manual.info.tmp, Node: performance-schema-replication-applier-configuration-table, Next: performance-schema-replication-applier-status-table, Prev: performance-schema-replication-connection-status-table, Up: performance-schema-replication-tables
25.12.11.3 The replication_applier_configuration Table ......................................................
This table shows the configuration parameters that affect transactions applied by the replica. Parameters stored in the table can be changed at runtime with the *note 'CHANGE MASTER TO': change-master-to. statement, as indicated in the column descriptions.
The *note 'replication_applier_configuration': performance-schema-replication-applier-configuration-table. table has these columns:
'CHANNEL_NAME'
The replication channel which this row is displaying. There is always a default replication channel, and more replication channels can be added. See *note replication-channels:: for more information.
'DESIRED_DELAY'
The number of seconds that the replica must lag the source. ('CHANGE MASTER TO' option: 'MASTER_DELAY')
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'replication_applier_configuration': performance-schema-replication-applier-configuration-table. table.
The following table shows the correspondence between note 'replication_applier_configuration ': performance-schema-replication-applier-configuration-table. columns and note 'SHOW SLAVE STATUS': show-slave-status. columns.
'replication_applier_configuration' 'SHOW SLAVE STATUS' Column Column
'DESIRED_DELAY' 'SQL_Delay'
File: manual.info.tmp, Node: performance-schema-replication-applier-status-table, Next: performance-schema-replication-applier-status-by-coordinator-table, Prev: performance-schema-replication-applier-configuration-table, Up: performance-schema-replication-tables
25.12.11.4 The replication_applier_status Table ...............................................
This table shows the current general transaction execution status on the replica. The table provides information about general aspects of transaction applier status that are not specific to any thread involved. Thread-specific status information is available in the note 'replication_applier_status_by_coordinator': performance-schema-replication-applier-status-by-coordinator-table. table (and note 'replication_applier_status_by_worker': performance-schema-replication-applier-status-by-worker-table. if the replica is multithreaded).
The *note 'replication_applier_status': performance-schema-replication-applier-status-table. table has these columns:
'CHANNEL_NAME'
The replication channel which this row is displaying. There is always a default replication channel, and more replication channels can be added. See *note replication-channels:: for more information.
'SERVICE_STATE'
Shows 'ON' when the replication channel's applier threads are active or idle, 'OFF' means that the applier threads are not active.
'REMAINING_DELAY'
If the replica is waiting for 'DESIRED_DELAY' seconds to pass since the source applied an event, this field contains the number of delay seconds remaining. At other times, this field is 'NULL'. (The 'DESIRED_DELAY' value is stored in the *note 'replication_applier_configuration': performance-schema-replication-applier-configuration-table. table.)
'COUNT_TRANSACTIONS_RETRIES'
Shows the number of retries that were made because the replication SQL thread failed to apply a transaction. The maximum number of retries for a given transaction is set by the 'slave_transaction_retries' system variable.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'replication_applier_status': performance-schema-replication-applier-status-table. table.
The following table shows the correspondence between note 'replication_applier_status': performance-schema-replication-applier-status-table. columns and note 'SHOW SLAVE STATUS': show-slave-status. columns.
'replication_applier_status' Column 'SHOW SLAVE STATUS' Column
'SERVICE_STATE' None
'REMAINING_DELAY' 'SQL_Remaining_Delay'
File: manual.info.tmp, Node: performance-schema-replication-applier-status-by-coordinator-table, Next: performance-schema-replication-applier-status-by-worker-table, Prev: performance-schema-replication-applier-status-table, Up: performance-schema-replication-tables
25.12.11.5 The replication_applier_status_by_coordinator Table ..............................................................
For a multithreaded replica, the replica uses multiple worker threads and a coordinator thread to manage them, and this table shows the status of the coordinator thread. For a single-threaded replica, this table is empty. For a multithreaded replica, the *note 'replication_applier_status_by_worker': performance-schema-replication-applier-status-by-worker-table. table shows the status of the worker threads.
The *note 'replication_applier_status_by_coordinator': performance-schema-replication-applier-status-by-coordinator-table. table has these columns:
'CHANNEL_NAME'
The replication channel which this row is displaying. There is always a default replication channel, and more replication channels can be added. See *note replication-channels:: for more information.
'THREAD_ID'
The SQL/coordinator thread ID.
'SERVICE_STATE'
'ON' (thread exists and is active or idle) or 'OFF' (thread no longer exists).
'LAST_ERROR_NUMBER', 'LAST_ERROR_MESSAGE'
The error number and error message of the most recent error that caused the SQL/coordinator thread to stop. An error number of 0 and message which is an empty string means 'no error'. If the 'LAST_ERROR_MESSAGE' value is not empty, the error values also appear in the replica's error log.
Issuing note 'RESET MASTER': reset-master. or note 'RESET SLAVE': reset-slave. resets the values shown in these columns.
All error codes and messages displayed in the 'LAST_ERROR_NUMBER' and 'LAST_ERROR_MESSAGE' columns correspond to error values listed in Server Error Message Reference (https://dev.mysql.com/doc/mysql-errors/5.7/en/server-error-reference.html).
'LAST_ERROR_TIMESTAMP'
A timestamp in YYMMDD HH:MM:SS format that shows when the most recent SQL/coordinator error occurred.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'replication_applier_status_by_coordinator': performance-schema-replication-applier-status-by-coordinator-table. table.
The following table shows the correspondence between note 'replication_applier_status_by_coordinator': performance-schema-replication-applier-status-by-coordinator-table. columns and note 'SHOW SLAVE STATUS': show-slave-status. columns.
'replication_applier_status_by_coordinator' 'SHOW SLAVE STATUS' Column Column
'THREAD_ID' None
'SERVICE_STATE' 'Slave_SQL_Running'
'LAST_ERROR_NUMBER' 'Last_SQL_Errno'
'LAST_ERROR_MESSAGE' 'Last_SQL_Error'
'LAST_ERROR_TIMESTAMP' 'Last_SQL_Error_Timestamp'
File: manual.info.tmp, Node: performance-schema-replication-applier-status-by-worker-table, Next: performance-schema-replication-group-member-stats-table, Prev: performance-schema-replication-applier-status-by-coordinator-table, Up: performance-schema-replication-tables
25.12.11.6 The replication_applier_status_by_worker Table .........................................................
If the replica is not multithreaded, this table shows the status of the applier thread. Otherwise, the replica uses multiple worker threads and a coordinator thread to manage them, and this table shows the status of the worker threads. For a multithreaded replica, the *note 'replication_applier_status_by_coordinator': performance-schema-replication-applier-status-by-coordinator-table. table shows the status of the coordinator thread.
The 'replication_applier_status_by_worker' table has these columns:
'CHANNEL_NAME'
The replication channel which this row is displaying. There is always a default replication channel, and more replication channels can be added. See *note replication-channels:: for more information.
'WORKER_ID'
The worker identifier (same value as the 'id' column in the 'mysql.slave_worker_info' table). After *note 'STOP SLAVE': stop-slave, the 'THREAD_ID' column becomes 'NULL', but the 'WORKER_ID' value is preserved.
'THREAD_ID'
The worker thread identifier.
'SERVICE_STATE'
'ON' (thread exists and is active or idle) or 'OFF' (thread no longer exists).
'LAST_SEEN_TRANSACTION'
The transaction that the worker has last seen. The worker has not necessarily applied this transaction because it could still be in the process of doing so.
If the 'gtid_mode' system variable value is 'OFF', this column is 'ANONYMOUS', indicating that transactions do not have global transaction identifiers (GTIDs) and are identified by file and position only.
If 'gtid_mode' is 'ON', the column value is defined as follows:
* If no transaction has executed, the column is empty.
* When a transaction has executed, the column is set from
'gtid_next' as soon as 'gtid_next' is set. From this moment,
the column always shows a GTID.
* The GTID is preserved until the next transaction is executed.
If an error occurs, the column value is the GTID of the
transaction being executed by the worker when the error
occurred. The following statement shows whether or not that
transaction has been committed:
SELECT GTID_SUBSET(LAST_SEEN_TRANSACTION, @@GLOBAL.GTID_EXECUTED)
FROM performance_schema.replication_applier_status_by_worker;
If the statement returns zero, the transaction has not yet
been committed, either because it is still being processed, or
because the worker thread was stopped while it was being
processed. If the statement returns nonzero, the transaction
has been committed.
'LAST_ERROR_NUMBER', 'LAST_ERROR_MESSAGE'
The error number and error message of the most recent error that caused the worker thread to stop. An error number of 0 and message of the empty string mean 'no error'. If the 'LAST_ERROR_MESSAGE' value is not empty, the error values also appear in the replica's error log.
Issuing note 'RESET MASTER': reset-master. or note 'RESET SLAVE': reset-slave. resets the values shown in these columns.
All error codes and messages displayed in the 'LAST_ERROR_NUMBER' and 'LAST_ERROR_MESSAGE' columns correspond to error values listed in Server Error Message Reference (https://dev.mysql.com/doc/mysql-errors/5.7/en/server-error-reference.html).
'LAST_ERROR_TIMESTAMP'
A timestamp in YYMMDD HH:MM:SS format that shows when the most recent worker error occurred.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'replication_applier_status_by_worker': performance-schema-replication-applier-status-by-worker-table. table.
The following table shows the correspondence between 'replication_applier_status_by_worker' columns and *note 'SHOW SLAVE STATUS': show-slave-status. columns.
'replication_applier_status_by_worker' 'SHOW SLAVE STATUS' Column Column
'WORKER_ID' None
'THREAD_ID' None
'SERVICE_STATE' None
'LAST_SEEN_TRANSACTION' None
'LAST_ERROR_NUMBER' 'Last_SQL_Errno'
'LAST_ERROR_MESSAGE' 'Last_SQL_Error'
'LAST_ERROR_TIMESTAMP' 'Last_SQL_Error_Timestamp'
File: manual.info.tmp, Node: performance-schema-replication-group-member-stats-table, Next: performance-schema-replication-group-members-table, Prev: performance-schema-replication-applier-status-by-worker-table, Up: performance-schema-replication-tables
25.12.11.7 The replication_group_member_stats Table ...................................................
This table shows statistical information for MySQL Group Replication members. It is populated only when Group Replication is running.
The 'replication_group_member_stats' table has these columns:
'CHANNEL_NAME'
Name of the Group Replication channel.
'VIEW_ID'
Current view identifier for this group.
'MEMBER_ID'
The member server UUID. This has a different value for each member in the group. This also serves as a key because it is unique to each member.
'COUNT_TRANSACTIONS_IN_QUEUE'
The number of transactions in the queue pending conflict detection checks. Once the transactions have been checked for conflicts, if they pass the check, they are queued to be applied as well.
'COUNT_TRANSACTIONS_CHECKED'
The number of transactions that have been checked for conflicts.
'COUNT_CONFLICTS_DETECTED'
The number of transactions that have not passed the conflict detection check.
'COUNT_TRANSACTIONS_ROWS_VALIDATING'
Number of transaction rows which can be used for certification, but have not been garbage collected. Can be thought of as the current size of the conflict detection database against which each transaction is certified.
'TRANSACTIONS_COMMITTED_ALL_MEMBERS'
The transactions that have been successfully committed on all members of the replication group, shown as *note replication-gtids-concepts-gtid-sets::. This is updated at a fixed time interval.
'LAST_CONFLICT_FREE_TRANSACTION'
The transaction identifier of the last conflict free transaction which was checked.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'replication_group_member_stats': performance-schema-replication-group-member-stats-table. table.
File: manual.info.tmp, Node: performance-schema-replication-group-members-table, Prev: performance-schema-replication-group-member-stats-table, Up: performance-schema-replication-tables
25.12.11.8 The replication_group_members Table ..............................................
This table shows network and status information for replication group members. The network addresses shown are the addresses used to connect clients to the group, and should not be confused with the member's internal group communication address specified by 'group_replication_local_address'.
The 'replication_group_members' table has these columns:
'CHANNEL_NAME'
Name of the Group Replication channel.
'MEMBER_ID'
Identifier for this member; the same as the server UUID.
'MEMBER_HOST'
Network address of this member (host name or IP address). Retrieved from the member's 'hostname' variable.
'MEMBER_PORT'
Port on which the server is listening. Retrieved from the member's 'port' variable.
'MEMBER_STATE'
Current state of this member; can be any one of the following:
* 'OFFLINE': The Group Replication plugin is installed but has
not been started.
* 'RECOVERING': The server has joined a group from which it is
retrieving data.
* 'ONLINE': The member is in a fully functioning state.
* 'ERROR': The member has encountered an error, either during
applying transactions or during the recovery phase, and is not
participating in the group's transactions.
* 'UNREACHABLE': The failure detection process suspects that
this member cannot be contacted, because the group messages
have timed out.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'replication_group_members': performance-schema-replication-group-members-table. table.
File: manual.info.tmp, Node: performance-schema-lock-tables, Next: performance-schema-system-variable-tables, Prev: performance-schema-replication-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-table-handles-table:: The table_handles Table
The Performance Schema exposes lock information through these tables:
*note 'metadata_locks': performance-schema-metadata-locks-table.: Metadata locks held and requested
*note 'table_handles': performance-schema-table-handles-table.: Table locks held and requested
The following sections describe these tables in more detail.
File: manual.info.tmp, Node: performance-schema-metadata-locks-table, Next: performance-schema-table-handles-table, Prev: performance-schema-lock-tables, Up: performance-schema-lock-tables
25.12.12.1 The metadata_locks Table ...................................
MySQL uses metadata locking to manage concurrent access to database objects and to ensure data consistency; see note metadata-locking::. Metadata locking applies not just to tables, but also to schemas, stored programs (procedures, functions, triggers, scheduled events), tablespaces, user locks acquired with the 'GET_LOCK()' function (see note locking-functions::), and locks acquired with the locking service described in *note locking-service::.
The Performance Schema exposes metadata lock information through the *note 'metadata_locks': performance-schema-metadata-locks-table. table:
Locks that have been granted (shows which sessions own which current metadata locks).
Locks that have been requested but not yet granted (shows which sessions are waiting for which metadata locks).
Lock requests that have been killed by the deadlock detector.
Lock requests that have timed out and are waiting for the requesting session's lock request to be discarded.
This information enables you to understand metadata lock dependencies between sessions. You can see not only which lock a session is waiting for, but which session currently holds that lock.
The *note 'metadata_locks': performance-schema-metadata-locks-table. table is read only and cannot be updated. It is autosized by default; to configure the table size, set the 'performance_schema_max_metadata_locks' system variable at server startup.
Metadata lock instrumentation uses the 'wait/lock/metadata/sql/mdl' instrument, which is disabled by default.
To control metadata lock instrumentation state at server startup, use lines like these in your 'my.cnf' file:
Enable:
[mysqld]
performance-schema-instrument='wait/lock/metadata/sql/mdl=ON'
Disable:
[mysqld]
performance-schema-instrument='wait/lock/metadata/sql/mdl=OFF'
To control metadata lock instrumentation state at runtime, update the *note 'setup_instruments': performance-schema-setup-instruments-table. table:
Enable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES', TIMED = 'YES'
WHERE NAME = 'wait/lock/metadata/sql/mdl';
Disable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'NO', TIMED = 'NO'
WHERE NAME = 'wait/lock/metadata/sql/mdl';
The Performance Schema maintains *note 'metadata_locks': performance-schema-metadata-locks-table. table content as follows, using the 'LOCK_STATUS' column to indicate the status of each lock:
When a metadata lock is requested and obtained immediately, a row with a status of 'GRANTED' is inserted.
When a metadata lock is requested and not obtained immediately, a row with a status of 'PENDING' is inserted.
When a metadata lock previously requested is granted, its row status is updated to 'GRANTED'.
When a metadata lock is released, its row is deleted.
When a pending lock request is canceled by the deadlock detector to break a deadlock ('ER_LOCK_DEADLOCK' (https://dev.mysql.com/doc/mysql-errors/5.7/en/server-error-reference.html#error_er_lock_deadlock)), its row status is updated from 'PENDING' to 'VICTIM'.
When a pending lock request times out ('ER_LOCK_WAIT_TIMEOUT' (https://dev.mysql.com/doc/mysql-errors/5.7/en/server-error-reference.html#error_er_lock_wait_timeout)), its row status is updated from 'PENDING' to 'TIMEOUT'.
When granted lock or pending lock request is killed, its row status is updated from 'GRANTED' or 'PENDING' to 'KILLED'.
The 'VICTIM', 'TIMEOUT', and 'KILLED' status values are brief and signify that the lock row is about to be deleted.
The 'PRE_ACQUIRE_NOTIFY' and 'POST_RELEASE_NOTIFY' status values are brief and signify that the metadata locking subsubsystem is notifying interested storage engines while entering lock acquisition operations or leaving lock release operations. These status values were added in MySQL 5.7.11.
The *note 'metadata_locks': performance-schema-metadata-locks-table. table has these columns:
'OBJECT_TYPE'
The type of lock used in the metadata lock subsystem. The value is one of 'GLOBAL', 'SCHEMA', 'TABLE', 'FUNCTION', 'PROCEDURE', 'TRIGGER' (currently unused), 'EVENT', 'COMMIT', 'USER LEVEL LOCK', 'TABLESPACE', or 'LOCKING SERVICE'.
A value of 'USER LEVEL LOCK' indicates a lock acquired with 'GET_LOCK()'. A value of 'LOCKING SERVICE' indicates a lock acquired with the locking service described in *note locking-service::.
'OBJECT_SCHEMA'
The schema that contains the object.
'OBJECT_NAME'
The name of the instrumented object.
'OBJECT_INSTANCE_BEGIN'
The address in memory of the instrumented object.
'LOCK_TYPE'
The lock type from the metadata lock subsystem. The value is one of 'INTENTION_EXCLUSIVE', 'SHARED', 'SHARED_HIGH_PRIO', 'SHARED_READ', 'SHARED_WRITE', 'SHARED_UPGRADABLE', 'SHARED_NO_WRITE', 'SHARED_NO_READ_WRITE', or 'EXCLUSIVE'.
'LOCK_DURATION'
The lock duration from the metadata lock subsystem. The value is one of 'STATEMENT', 'TRANSACTION', or 'EXPLICIT'. The 'STATEMENT' and 'TRANSACTION' values signify locks that are released implicitly at statement or transaction end, respectively. The 'EXPLICIT' value signifies locks that survive statement or transaction end and are released by explicit action, such as global locks acquired with 'FLUSH TABLES WITH READ LOCK'.
'LOCK_STATUS'
The lock status from the metadata lock subsystem. The value is one of 'PENDING', 'GRANTED', 'VICTIM', 'TIMEOUT', 'KILLED', 'PRE_ACQUIRE_NOTIFY', or 'POST_RELEASE_NOTIFY'. The Performance Schema assigns these values as described previously.
'SOURCE'
The name of the source file containing the instrumented code that produced the event and the line number in the file at which the instrumentation occurs. This enables you to check the source to determine exactly what code is involved.
'OWNER_THREAD_ID'
The thread requesting a metadata lock.
'OWNER_EVENT_ID'
The event requesting a metadata lock.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'metadata_locks': performance-schema-metadata-locks-table. table.
File: manual.info.tmp, Node: performance-schema-table-handles-table, Prev: performance-schema-metadata-locks-table, Up: performance-schema-lock-tables
25.12.12.2 The table_handles Table ..................................
The Performance Schema exposes table lock information through the note 'table_handles': performance-schema-table-handles-table. table to show the table locks currently in effect for each opened table handle. note 'table_handles': performance-schema-table-handles-table. reports what is recorded by the table lock instrumentation. This information shows which table handles the server has open, how they are locked, and by which sessions.
The *note 'table_handles': performance-schema-table-handles-table. table is read only and cannot be updated. It is autosized by default; to configure the table size, set the 'performance_schema_max_table_handles' system variable at server startup.
Table lock instrumentation uses the 'wait/lock/table/sql/handler' instrument, which is enabled by default.
To control table lock instrumentation state at server startup, use lines like these in your 'my.cnf' file:
Enable:
[mysqld]
performance-schema-instrument='wait/lock/table/sql/handler=ON'
Disable:
[mysqld]
performance-schema-instrument='wait/lock/table/sql/handler=OFF'
To control table lock instrumentation state at runtime, update the *note 'setup_instruments': performance-schema-setup-instruments-table. table:
Enable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES', TIMED = 'YES'
WHERE NAME = 'wait/lock/table/sql/handler';
Disable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'NO', TIMED = 'NO'
WHERE NAME = 'wait/lock/table/sql/handler';
The *note 'table_handles': performance-schema-table-handles-table. table has these columns:
'OBJECT_TYPE'
The table opened by a table handle.
'OBJECT_SCHEMA'
The schema that contains the object.
'OBJECT_NAME'
The name of the instrumented object.
'OBJECT_INSTANCE_BEGIN'
The table handle address in memory.
'OWNER_THREAD_ID'
The thread owning the table handle.
'OWNER_EVENT_ID'
The event which caused the table handle to be opened.
'INTERNAL_LOCK'
The table lock used at the SQL level. The value is one of 'READ', 'READ WITH SHARED LOCKS', 'READ HIGH PRIORITY', 'READ NO INSERT', 'WRITE ALLOW WRITE', 'WRITE CONCURRENT INSERT', 'WRITE LOW PRIORITY', or 'WRITE'. For information about these lock types, see the 'include/thr_lock.h' source file.
'EXTERNAL_LOCK'
The table lock used at the storage engine level. The value is one of 'READ EXTERNAL' or 'WRITE EXTERNAL'.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'table_handles': performance-schema-table-handles-table. table.
File: manual.info.tmp, Node: performance-schema-system-variable-tables, Next: performance-schema-status-variable-tables, Prev: performance-schema-lock-tables, Up: performance-schema-table-descriptions
Note:
The value of the 'show_compatibility_56' system variable affects the information available from the tables described here. For details, see the description of that variable in *note server-system-variables::.
The MySQL server maintains many system variables that indicate how it is configured (see *note server-system-variables::). System variable information is available in these Performance Schema tables:
*note 'global_variables': performance-schema-system-variable-tables.: Global system variables. An application that wants only global values should use this table.
*note 'session_variables': performance-schema-system-variable-tables.: System variables for the current session. An application that wants all system variable values for its own session should use this table. It includes the session variables for its session, as well as the values of global variables that have no session counterpart.
*note 'variables_by_thread': performance-schema-system-variable-tables.: Session system variables for each active session. An application that wants to know the session variable values for specific sessions should use this table. It includes session variables only, identified by thread ID.
The session variable tables (note 'session_variables': performance-schema-system-variable-tables, note 'variables_by_thread': performance-schema-system-variable-tables.) contain information only for active sessions, not terminated sessions.
The note 'global_variables': performance-schema-system-variable-tables. and note 'session_variables': performance-schema-system-variable-tables. tables have these columns:
'VARIABLE_NAME'
The system variable name.
'VARIABLE_VALUE'
The system variable value. For note 'global_variables': performance-schema-system-variable-tables, this column contains the global value. For note 'session_variables': performance-schema-system-variable-tables, this column contains the variable value in effect for the current session.
The *note 'variables_by_thread': performance-schema-system-variable-tables. table has these columns:
'THREAD_ID'
The thread identifier of the session in which the system variable is defined.
'VARIABLE_NAME'
The system variable name.
'VARIABLE_VALUE'
The session variable value for the session named by the 'THREAD_ID' column.
The *note 'variables_by_thread': performance-schema-system-variable-tables. table contains system variable information only about foreground threads. If not all threads are instrumented by the Performance Schema, this table may miss some rows. In this case, the 'Performance_schema_thread_instances_lost' status variable is greater than zero.
*note 'TRUNCATE TABLE': truncate-table. is not supported for Performance Schema system variable tables.
File: manual.info.tmp, Node: performance-schema-status-variable-tables, Next: performance-schema-summary-tables, Prev: performance-schema-system-variable-tables, Up: performance-schema-table-descriptions
Note:
The value of the 'show_compatibility_56' system variable affects the information available from the tables described here. For details, see the description of that variable in *note server-system-variables::.
The MySQL server maintains many status variables that provide information about its operation (see *note server-status-variables::). Status variable information is available in these Performance Schema tables:
*note 'global_status': performance-schema-status-variable-tables.: Global status variables. An application that wants only global values should use this table.
*note 'session_status': performance-schema-status-variable-tables.: Status variables for the current session. An application that wants all status variable values for its own session should use this table. It includes the session variables for its session, as well as the values of global variables that have no session counterpart.
*note 'status_by_thread': performance-schema-status-variable-tables.: Session status variables for each active session. An application that wants to know the session variable values for specific sessions should use this table. It includes session variables only, identified by thread ID.
There are also summary tables that provide status variable information aggregated by account, host name, and user name. See *note performance-schema-status-variable-summary-tables::.
The session variable tables (note 'session_status': performance-schema-status-variable-tables, note 'status_by_thread': performance-schema-status-variable-tables.) contain information only for active sessions, not terminated sessions.
The Performance Schema collects statistics for global status variables only for threads for which the 'INSTRUMENTED' value is 'YES' in the *note 'threads': performance-schema-threads-table. table. Statistics for session status variables are always collected, regardless of the 'INSTRUMENTED' value.
The Performance Schema does not collect statistics for 'Com_XXX' status variables in the status variable tables. To obtain global and per-session statement execution counts, use the note 'events_statements_summary_global_by_event_name': performance-schema-statement-summary-tables. and note 'events_statements_summary_by_thread_by_event_name': performance-schema-statement-summary-tables. tables, respectively. For example:
SELECT EVENT_NAME, COUNT_STAR
FROM performance_schema.events_statements_summary_global_by_event_name
WHERE EVENT_NAME LIKE 'statement/sql/%';
The note 'global_status': performance-schema-status-variable-tables. and note 'session_status': performance-schema-status-variable-tables. tables have these columns:
'VARIABLE_NAME'
The status variable name.
'VARIABLE_VALUE'
The status variable value. For note 'global_status': performance-schema-status-variable-tables, this column contains the global value. For note 'session_status': performance-schema-status-variable-tables, this column contains the variable value for the current session.
The *note 'status_by_thread': performance-schema-status-variable-tables. table contains the status of each active thread. It has these columns:
'THREAD_ID'
The thread identifier of the session in which the status variable is defined.
'VARIABLE_NAME'
The status variable name.
'VARIABLE_VALUE'
The session variable value for the session named by the 'THREAD_ID' column.
The *note 'status_by_thread': performance-schema-status-variable-tables. table contains status variable information only about foreground threads. If the 'performance_schema_max_thread_instances' system variable is not autoscaled (signified by a value of −1) and the maximum permitted number of instrumented thread objects is not greater than the number of background threads, the table is empty.
The Performance Schema supports *note 'TRUNCATE TABLE': truncate-table. for status variable tables as follows:
*note 'global_status': performance-schema-status-variable-tables.: Resets thread, account, host, and user status. Resets global status variables except those that the server never resets.
*note 'session_status': performance-schema-status-variable-tables.: Not supported.
*note 'status_by_thread': performance-schema-status-variable-tables.: Aggregates status for all threads to the global status and account status, then resets thread status. If account statistics are not collected, the session status is added to host and user status, if host and user status are collected.
Account, host, and user statistics are not collected if the 'performance_schema_accounts_size', 'performance_schema_hosts_size', and 'performance_schema_users_size' system variables, respectively, are set to 0.
'FLUSH STATUS' adds the session status from all active sessions to the global status variables, resets the status of all active sessions, and resets account, host, and user status values aggregated from disconnected sessions.
File: manual.info.tmp, Node: performance-schema-summary-tables, Next: performance-schema-miscellaneous-tables, Prev: performance-schema-status-variable-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-status-variable-summary-tables:: Status Variable Summary Tables
Summary tables provide aggregated information for terminated events over time. The tables in this group summarize event data in different ways.
Each summary table has grouping columns that determine how to group the data to be aggregated, and summary columns that contain the aggregated values. Tables that summarize events in similar ways often have similar sets of summary columns and differ only in the grouping columns used to determine how events are aggregated.
Summary tables can be truncated with *note 'TRUNCATE TABLE': truncate-table. Generally, the effect is to reset the summary columns to 0 or 'NULL', not to remove rows. This enables you to clear collected values and restart aggregation. That might be useful, for example, after you have made a runtime configuration change. Exceptions to this truncation behavior are noted in individual summary table sections.
Wait Event Summaries
Performance Schema Wait Event Summary Tables
Table Name Description
*note 'events_waits_summary_by_account_by_event_name': performance-schema-wait-summary-tables.Wait events per account and event name
*note 'events_waits_summary_by_host_by_event_name': performance-schema-wait-summary-tables.Wait events per host name and event name
*note 'events_waits_summary_by_instance': performance-schema-wait-summary-tables.Wait events per instance
*note 'events_waits_summary_by_thread_by_event_name': performance-schema-wait-summary-tables.Wait events per thread and event name
*note 'events_waits_summary_by_user_by_event_name': performance-schema-wait-summary-tables.Wait events per user name and event name
*note 'events_waits_summary_global_by_event_name': performance-schema-wait-summary-tables.Wait events per event name
Stage Summaries
Performance Schema Stage Event Summary Tables
Table Name Description
*note 'events_stages_summary_by_account_by_event_name': performance-schema-stage-summary-tables.Stage events per account and event name
*note 'events_stages_summary_by_host_by_event_name': performance-schema-stage-summary-tables.Stage events per host name and event name
*note 'events_stages_summary_by_thread_by_event_name': performance-schema-stage-summary-tables.Stage waits per thread and event name
*note 'events_stages_summary_by_user_by_event_name': performance-schema-stage-summary-tables.Stage events per user name and event name
*note 'events_stages_summary_global_by_event_name': performance-schema-stage-summary-tables.Stage waits per event name
Statement Summaries
Performance Schema Statement Event Summary Tables
Table Name Description
*note 'events_statements_summary_by_account_by_event_name': performance-schema-statement-summary-tables.Statement events per account and event name
*note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables.Statement events per schema and digest value
*note 'events_statements_summary_by_host_by_event_name': performance-schema-statement-summary-tables.Statement events per host name and event name
*note 'events_statements_summary_by_program': performance-schema-statement-summary-tables.Statement events per stored program
*note 'events_statements_summary_by_thread_by_event_name': performance-schema-statement-summary-tables.Statement events per thread and event name
*note 'events_statements_summary_by_user_by_event_name': performance-schema-statement-summary-tables.Statement events per user name and event name
*note 'events_statements_summary_global_by_event_name': performance-schema-statement-summary-tables.Statement events per event name
*note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table.Prepared statement instances and statistics
Transaction Summaries
Performance Schema Transaction Event Summary Tables
Table Name Description
*note 'events_transactions_summary_by_account_by_event_name': performance-schema-transaction-summary-tables.Transaction events per account and event name
*note 'events_transactions_summary_by_host_by_event_name': performance-schema-transaction-summary-tables.Transaction events per host name and event name
*note 'events_transactions_summary_by_thread_by_event_name': performance-schema-transaction-summary-tables.Transaction events per thread and event name
*note 'events_transactions_summary_by_user_by_event_name': performance-schema-transaction-summary-tables.Transaction events per user name and event name
*note 'events_transactions_summary_global_by_event_name': performance-schema-transaction-summary-tables.Transaction events per event name
Object Wait Summaries
Performance Schema Object Event Summary Tables
Table Name Description
*note 'objects_summary_global_by_type': performance-schema-objects-summary-global-by-type-table.Object summaries
File I/O Summaries
Performance Schema File I/O Event Summary Tables
Table Name Description
*note 'file_summary_by_event_name': performance-schema-file-summary-tables.File events per event name
*note 'file_summary_by_instance': performance-schema-file-summary-tables.File events per file instance
Table I/O and Lock Wait Summaries
Performance Schema Table I/O and Lock Wait Event Summary Tables
Table Name Description
*note 'table_io_waits_summary_by_index_usage': performance-schema-table-io-waits-summary-by-index-usage-table.Table I/O waits per index
*note 'table_io_waits_summary_by_table': performance-schema-table-io-waits-summary-by-table-table.Table I/O waits per table
*note 'table_lock_waits_summary_by_table': performance-schema-table-lock-waits-summary-by-table-table.Table lock waits per table
Socket Summaries
Performance Schema Socket Event Summary Tables
Table Name Description
*note 'socket_summary_by_event_name': performance-schema-socket-summary-tables.Socket waits and I/O per event name
*note 'socket_summary_by_instance': performance-schema-socket-summary-tables.Socket waits and I/O per instance
Memory Summaries
Performance Schema Memory Operation Summary Tables
Table Name Description
*note 'memory_summary_by_account_by_event_name': performance-schema-memory-summary-tables.Memory operations per account and event name
*note 'memory_summary_by_host_by_event_name': performance-schema-memory-summary-tables.Memory operations per host and event name
*note 'memory_summary_by_thread_by_event_name': performance-schema-memory-summary-tables.Memory operations per thread and event name
*note 'memory_summary_by_user_by_event_name': performance-schema-memory-summary-tables.Memory operations per user and event name
*note 'memory_summary_global_by_event_name': performance-schema-memory-summary-tables.Memory operations globally per event name
Status Variable Summaries
Performance Schema Error Status Variable Summary Tables
Table Name Description
*note 'status_by_account': performance-schema-status-variable-summary-tables.Session status variables per account
*note 'status_by_host': performance-schema-status-variable-summary-tables.Session status variables per host name
*note 'status_by_user': performance-schema-status-variable-summary-tables.Session status variables per user name
File: manual.info.tmp, Node: performance-schema-wait-summary-tables, Next: performance-schema-stage-summary-tables, Prev: performance-schema-summary-tables, Up: performance-schema-summary-tables
25.12.15.1 Wait Event Summary Tables ....................................
The Performance Schema maintains tables for collecting current and recent wait events, and aggregates that information in summary tables. *note performance-schema-wait-tables:: describes the events on which wait summaries are based. See that discussion for information about the content of wait events, the current and recent wait event tables, and how to control wait event collection, which is disabled by default.
Example wait event summary information:
mysql> SELECT *
FROM performance_schema.events_waits_summary_global_by_event_name\G
...
*************************** 6. row ***************************
EVENT_NAME: wait/synch/mutex/sql/BINARY_LOG::LOCK_index
COUNT_STAR: 8
SUM_TIMER_WAIT: 2119302
MIN_TIMER_WAIT: 196092
AVG_TIMER_WAIT: 264912
MAX_TIMER_WAIT: 569421
...
*************************** 9. row ***************************
EVENT_NAME: wait/synch/mutex/sql/hash_filo::lock
COUNT_STAR: 69
SUM_TIMER_WAIT: 16848828
MIN_TIMER_WAIT: 0
AVG_TIMER_WAIT: 244185
MAX_TIMER_WAIT: 735345
...
Each wait event summary table has one or more grouping columns to indicate how the table aggregates events. Event names refer to names of event instruments in the *note 'setup_instruments': performance-schema-setup-instruments-table. table:
*note 'events_waits_summary_by_account_by_event_name': performance-schema-stage-summary-tables. has 'EVENT_NAME', 'USER', and 'HOST' columns. Each row summarizes events for a given account (user and host combination) and event name.
*note 'events_waits_summary_by_host_by_event_name': performance-schema-stage-summary-tables. has 'EVENT_NAME' and 'HOST' columns. Each row summarizes events for a given host and event name.
*note 'events_waits_summary_by_instance': performance-schema-wait-summary-tables. has 'EVENT_NAME' and 'OBJECT_INSTANCE_BEGIN' columns. Each row summarizes events for a given event name and object. If an instrument is used to create multiple instances, each instance has a unique 'OBJECT_INSTANCE_BEGIN' value and is summarized separately in this table.
*note 'events_waits_summary_by_thread_by_event_name': performance-schema-wait-summary-tables. has 'THREAD_ID' and 'EVENT_NAME' columns. Each row summarizes events for a given thread and event name.
*note 'events_waits_summary_by_user_by_event_name': performance-schema-stage-summary-tables. has 'EVENT_NAME' and 'USER' columns. Each row summarizes events for a given user and event name.
*note 'events_waits_summary_global_by_event_name': performance-schema-wait-summary-tables. has an 'EVENT_NAME' column. Each row summarizes events for a given event name. An instrument might be used to create multiple instances of the instrumented object. For example, if there is an instrument for a mutex that is created for each connection, there are as many instances as there are connections. The summary row for the instrument summarizes over all these instances.
Each wait event summary table has these summary columns containing aggregated values:
'COUNT_STAR'
The number of summarized events. This value includes all events, whether timed or nontimed.
'SUM_TIMER_WAIT'
The total wait time of the summarized timed events. This value is calculated only for timed events because nontimed events have a wait time of 'NULL'. The same is true for the other 'XXX_TIMER_WAIT' values.
'MIN_TIMER_WAIT'
The minimum wait time of the summarized timed events.
'AVG_TIMER_WAIT'
The average wait time of the summarized timed events.
'MAX_TIMER_WAIT'
The maximum wait time of the summarized timed events.
*note 'TRUNCATE TABLE': truncate-table. is permitted for wait summary tables. It has these effects:
For summary tables not aggregated by account, host, or user, truncation resets the summary columns to zero rather than removing rows.
For summary tables aggregated by account, host, or user, truncation removes rows for accounts, hosts, or users with no connections, and resets the summary columns to zero for the remaining rows.
In addition, each wait summary table that is aggregated by account, host, user, or thread is implicitly truncated by truncation of the connection table on which it depends, or truncation of note 'events_waits_summary_global_by_event_name': performance-schema-wait-summary-tables. For details, see note performance-schema-connection-tables::.
File: manual.info.tmp, Node: performance-schema-stage-summary-tables, Next: performance-schema-statement-summary-tables, Prev: performance-schema-wait-summary-tables, Up: performance-schema-summary-tables
25.12.15.2 Stage Summary Tables ...............................
The Performance Schema maintains tables for collecting current and recent stage events, and aggregates that information in summary tables. *note performance-schema-stage-tables:: describes the events on which stage summaries are based. See that discussion for information about the content of stage events, the current and historical stage event tables, and how to control stage event collection, which is disabled by default.
Example stage event summary information:
mysql> SELECT *
FROM performance_schema.events_stages_summary_global_by_event_name\G
...
*************************** 5. row ***************************
EVENT_NAME: stage/sql/checking permissions
COUNT_STAR: 57
SUM_TIMER_WAIT: 26501888880
MIN_TIMER_WAIT: 7317456
AVG_TIMER_WAIT: 464945295
MAX_TIMER_WAIT: 12858936792
...
*************************** 9. row ***************************
EVENT_NAME: stage/sql/closing tables
COUNT_STAR: 37
SUM_TIMER_WAIT: 662606568
MIN_TIMER_WAIT: 1593864
AVG_TIMER_WAIT: 17907891
MAX_TIMER_WAIT: 437977248
...
Each stage summary table has one or more grouping columns to indicate how the table aggregates events. Event names refer to names of event instruments in the *note 'setup_instruments': performance-schema-setup-instruments-table. table:
*note 'events_stages_summary_by_account_by_event_name': performance-schema-stage-summary-tables. has 'EVENT_NAME', 'USER', and 'HOST' columns. Each row summarizes events for a given account (user and host combination) and event name.
*note 'events_stages_summary_by_host_by_event_name': performance-schema-stage-summary-tables. has 'EVENT_NAME' and 'HOST' columns. Each row summarizes events for a given host and event name.
*note 'events_stages_summary_by_thread_by_event_name': performance-schema-stage-summary-tables. has 'THREAD_ID' and 'EVENT_NAME' columns. Each row summarizes events for a given thread and event name.
*note 'events_stages_summary_by_user_by_event_name': performance-schema-stage-summary-tables. has 'EVENT_NAME' and 'USER' columns. Each row summarizes events for a given user and event name.
*note 'events_stages_summary_global_by_event_name': performance-schema-stage-summary-tables. has an 'EVENT_NAME' column. Each row summarizes events for a given event name.
Each stage summary table has these summary columns containing aggregated values: 'COUNT_STAR', 'SUM_TIMER_WAIT', 'MIN_TIMER_WAIT', 'AVG_TIMER_WAIT', and 'MAX_TIMER_WAIT'. These columns are analogous to the columns of the same names in the wait event summary tables (see note performance-schema-wait-summary-tables::), except that the stage summary tables aggregate events from note 'events_stages_current': performance-schema-events-stages-current-table. rather than *note 'events_waits_current': performance-schema-events-waits-current-table.
*note 'TRUNCATE TABLE': truncate-table. is permitted for stage summary tables. It has these effects:
For summary tables not aggregated by account, host, or user, truncation resets the summary columns to zero rather than removing rows.
For summary tables aggregated by account, host, or user, truncation removes rows for accounts, hosts, or users with no connections, and resets the summary columns to zero for the remaining rows.
In addition, each stage summary table that is aggregated by account, host, user, or thread is implicitly truncated by truncation of the connection table on which it depends, or truncation of note 'events_stages_summary_global_by_event_name': performance-schema-stage-summary-tables. For details, see note performance-schema-connection-tables::.
File: manual.info.tmp, Node: performance-schema-statement-summary-tables, Next: performance-schema-transaction-summary-tables, Prev: performance-schema-stage-summary-tables, Up: performance-schema-summary-tables
25.12.15.3 Statement Summary Tables ...................................
The Performance Schema maintains tables for collecting current and recent statement events, and aggregates that information in summary tables. *note performance-schema-statement-tables:: describes the events on which statement summaries are based. See that discussion for information about the content of statement events, the current and historical statement event tables, and how to control statement event collection, which is partially disabled by default.
Example statement event summary information:
mysql> SELECT *
FROM performance_schema.events_statements_summary_global_by_event_name\G
*************************** 1. row ***************************
EVENT_NAME: statement/sql/select
COUNT_STAR: 25
SUM_TIMER_WAIT: 1535983999000
MIN_TIMER_WAIT: 209823000
AVG_TIMER_WAIT: 61439359000
MAX_TIMER_WAIT: 1363397650000
SUM_LOCK_TIME: 20186000000
SUM_ERRORS: 0
SUM_WARNINGS: 0
SUM_ROWS_AFFECTED: 0
SUM_ROWS_SENT: 388
SUM_ROWS_EXAMINED: 370
SUM_CREATED_TMP_DISK_TABLES: 0
SUM_CREATED_TMP_TABLES: 0
SUM_SELECT_FULL_JOIN: 0
SUM_SELECT_FULL_RANGE_JOIN: 0
SUM_SELECT_RANGE: 0
SUM_SELECT_RANGE_CHECK: 0
SUM_SELECT_SCAN: 6
SUM_SORT_MERGE_PASSES: 0
SUM_SORT_RANGE: 0
SUM_SORT_ROWS: 0
SUM_SORT_SCAN: 0
SUM_NO_INDEX_USED: 6
SUM_NO_GOOD_INDEX_USED: 0
...
Each statement summary table has one or more grouping columns to indicate how the table aggregates events. Event names refer to names of event instruments in the *note 'setup_instruments': performance-schema-setup-instruments-table. table:
*note 'events_statements_summary_by_account_by_event_name': performance-schema-statement-summary-tables. has 'EVENT_NAME', 'USER', and 'HOST' columns. Each row summarizes events for a given account (user and host combination) and event name.
*note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables. has 'SCHEMA_NAME' and 'DIGEST' columns. Each row summarizes events per schema and digest value. (The 'DIGEST_TEXT' column contains the corresponding normalized statement digest text, but is neither a grouping nor a summary column.)
The maximum number of rows in the table is autosized at server startup. To set this maximum explicitly, set the 'performance_schema_digests_size' system variable at server startup.
*note 'events_statements_summary_by_host_by_event_name': performance-schema-statement-summary-tables. has 'EVENT_NAME' and 'HOST' columns. Each row summarizes events for a given host and event name.
*note 'events_statements_summary_by_program': performance-schema-statement-summary-tables. has 'OBJECT_TYPE', 'OBJECT_SCHEMA', and 'OBJECT_NAME' columns. Each row summarizes events for a given stored program (stored procedure or function, trigger, or event).
*note 'events_statements_summary_by_thread_by_event_name': performance-schema-statement-summary-tables. has 'THREAD_ID' and 'EVENT_NAME' columns. Each row summarizes events for a given thread and event name.
*note 'events_statements_summary_by_user_by_event_name': performance-schema-statement-summary-tables. has 'EVENT_NAME' and 'USER' columns. Each row summarizes events for a given user and event name.
*note 'events_statements_summary_global_by_event_name': performance-schema-statement-summary-tables. has an 'EVENT_NAME' column. Each row summarizes events for a given event name.
*note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table. has an 'OBJECT_INSTANCE_BEGIN' column. Each row summarizes events for a given prepared statement.
Each statement summary table has these summary columns containing aggregated values (with exceptions as noted):
'COUNT_STAR', 'SUM_TIMER_WAIT', 'MIN_TIMER_WAIT', 'AVG_TIMER_WAIT', 'MAX_TIMER_WAIT'
These columns are analogous to the columns of the same names in the wait event summary tables (see note performance-schema-wait-summary-tables::), except that the statement summary tables aggregate events from note 'events_statements_current': performance-schema-events-statements-current-table. rather than *note 'events_waits_current': performance-schema-events-waits-current-table.
The *note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table. table does not have these columns.
'SUM_XXX'
The aggregate of the corresponding XXX column in the note 'events_statements_current': performance-schema-events-statements-current-table. table. For example, the 'SUM_LOCK_TIME' and 'SUM_ERRORS' columns in statement summary tables are the aggregates of the 'LOCK_TIME' and 'ERRORS' columns in note 'events_statements_current': performance-schema-events-statements-current-table. table.
The *note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables. table has these additional summary columns:
'FIRST_SEEN', 'LAST_SEEN'
Timestamps indicating when statements with the given digest value were first seen and most recently seen.
The *note 'events_statements_summary_by_program': performance-schema-statement-summary-tables. table has these additional summary columns:
'COUNT_STATEMENTS', 'SUM_STATEMENTS_WAIT', 'MIN_STATEMENTS_WAIT', 'AVG_STATEMENTS_WAIT', 'MAX_STATEMENTS_WAIT'
Statistics about nested statements invoked during stored program execution.
The *note 'prepared_statements_instances': performance-schema-prepared-statements-instances-table. table has these additional summary columns:
'COUNT_EXECUTE', 'SUM_TIMER_EXECUTE', 'MIN_TIMER_EXECUTE', 'AVG_TIMER_EXECUTE', 'MAX_TIMER_EXECUTE'
Aggregated statistics for executions of the prepared statement.
*note 'TRUNCATE TABLE': truncate-table. is permitted for statement summary tables. It has these effects:
For *note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables, it removes the rows.
For other summary tables not aggregated by account, host, or user, truncation resets the summary columns to zero rather than removing rows.
For other summary tables aggregated by account, host, or user, truncation removes rows for accounts, hosts, or users with no connections, and resets the summary columns to zero for the remaining rows.
In addition, each statement summary table that is aggregated by account, host, user, or thread is implicitly truncated by truncation of the connection table on which it depends, or truncation of note 'events_statements_summary_global_by_event_name': performance-schema-statement-summary-tables. For details, see note performance-schema-connection-tables::.
Statement Digest Aggregation Rules
If the 'statements_digest' consumer is enabled, aggregation into *note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables. occurs as follows when a statement completes. Aggregation is based on the 'DIGEST' value computed for the statement.
If a *note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables. row already exists with the digest value for the statement that just completed, statistics for the statement are aggregated to that row. The 'LAST_SEEN' column is updated to the current time.
If no row has the digest value for the statement that just completed, and the table is not full, a new row is created for the statement. The 'FIRST_SEEN' and 'LAST_SEEN' columns are initialized with the current time.
If no row has the statement digest value for the statement that just completed, and the table is full, the statistics for the statement that just completed are added to a special 'catch-all' row with 'DIGEST' = 'NULL', which is created if necessary. If the row is created, the 'FIRST_SEEN' and 'LAST_SEEN' columns are initialized with the current time. Otherwise, the 'LAST_SEEN' column is updated with the current time.
The row with 'DIGEST' = 'NULL' is maintained because Performance Schema tables have a maximum size due to memory constraints. The 'DIGEST' = 'NULL' row permits digests that do not match other rows to be counted even if the summary table is full, using a common 'other' bucket. This row helps you estimate whether the digest summary is representative:
A 'DIGEST' = 'NULL' row that has a 'COUNT_STAR' value that represents 5% of all digests shows that the digest summary table is very representative; the other rows cover 95% of the statements seen.
A 'DIGEST' = 'NULL' row that has a 'COUNT_STAR' value that represents 50% of all digests shows that the digest summary table is not very representative; the other rows cover only half the statements seen. Most likely the DBA should increase the maximum table size so that more of the rows counted in the 'DIGEST' = 'NULL' row would be counted using more specific rows instead. By default, the table is autosized, but if this size is too small, set the 'performance_schema_digests_size' system variable to a larger value at server startup.
Stored Program Instrumentation Behavior
For stored program types for which instrumentation is enabled in the note 'setup_objects': performance-schema-setup-objects-table. table, note 'events_statements_summary_by_program': performance-schema-statement-summary-tables. maintains statistics for stored programs as follows:
A row is added for an object when it is first used in the server.
The row for an object is removed when the object is dropped.
Statistics are aggregated in the row for an object as it executes.
See also *note performance-schema-pre-filtering::.
File: manual.info.tmp, Node: performance-schema-transaction-summary-tables, Next: performance-schema-objects-summary-global-by-type-table, Prev: performance-schema-statement-summary-tables, Up: performance-schema-summary-tables
25.12.15.4 Transaction Summary Tables .....................................
The Performance Schema maintains tables for collecting current and recent transaction events, and aggregates that information in summary tables. *note performance-schema-transaction-tables:: describes the events on which transaction summaries are based. See that discussion for information about the content of transaction events, the current and historical transaction event tables, and how to control transaction event collection, which is disabled by default.
Example transaction event summary information:
mysql> SELECT *
FROM performance_schema.events_transactions_summary_global_by_event_name
LIMIT 1\G
*************************** 1. row ***************************
EVENT_NAME: transaction
COUNT_STAR: 5
SUM_TIMER_WAIT: 19550092000
MIN_TIMER_WAIT: 2954148000
AVG_TIMER_WAIT: 3910018000
MAX_TIMER_WAIT: 5486275000
COUNT_READ_WRITE: 5
SUM_TIMER_READ_WRITE: 19550092000
MIN_TIMER_READ_WRITE: 2954148000
AVG_TIMER_READ_WRITE: 3910018000
MAX_TIMER_READ_WRITE: 5486275000
COUNT_READ_ONLY: 0
SUM_TIMER_READ_ONLY: 0
MIN_TIMER_READ_ONLY: 0
AVG_TIMER_READ_ONLY: 0
MAX_TIMER_READ_ONLY: 0
Each transaction summary table has one or more grouping columns to indicate how the table aggregates events. Event names refer to names of event instruments in the *note 'setup_instruments': performance-schema-setup-instruments-table. table:
*note 'events_transactions_summary_by_account_by_event_name': performance-schema-transaction-summary-tables. has 'USER', 'HOST', and 'EVENT_NAME' columns. Each row summarizes events for a given account (user and host combination) and event name.
*note 'events_transactions_summary_by_host_by_event_name': performance-schema-transaction-summary-tables. has 'HOST' and 'EVENT_NAME' columns. Each row summarizes events for a given host and event name.
*note 'events_transactions_summary_by_thread_by_event_name': performance-schema-transaction-summary-tables. has 'THREAD_ID' and 'EVENT_NAME' columns. Each row summarizes events for a given thread and event name.
*note 'events_transactions_summary_by_user_by_event_name': performance-schema-transaction-summary-tables. has 'USER' and 'EVENT_NAME' columns. Each row summarizes events for a given user and event name.
*note 'events_transactions_summary_global_by_event_name': performance-schema-transaction-summary-tables. has an 'EVENT_NAME' column. Each row summarizes events for a given event name.
Each transaction summary table has these summary columns containing aggregated values:
'COUNT_STAR', 'SUM_TIMER_WAIT', 'MIN_TIMER_WAIT', 'AVG_TIMER_WAIT', 'MAX_TIMER_WAIT'
These columns are analogous to the columns of the same names in the wait event summary tables (see note performance-schema-wait-summary-tables::), except that the transaction summary tables aggregate events from note 'events_transactions_current': performance-schema-events-transactions-current-table. rather than *note 'events_waits_current': performance-schema-events-waits-current-table. These columns summarize read-write and read-only transactions.
'COUNT_READ_WRITE', 'SUM_TIMER_READ_WRITE', 'MIN_TIMER_READ_WRITE', 'AVG_TIMER_READ_WRITE', 'MAX_TIMER_READ_WRITE'
These are similar to the 'COUNT_STAR' and 'XXX_TIMER_WAIT' columns, but summarize read-write transactions only. The transaction access mode specifies whether transactions operate in read/write or read-only mode.
'COUNT_READ_ONLY', 'SUM_TIMER_READ_ONLY', 'MIN_TIMER_READ_ONLY', 'AVG_TIMER_READ_ONLY', 'MAX_TIMER_READ_ONLY'
These are similar to the 'COUNT_STAR' and 'XXX_TIMER_WAIT' columns, but summarize read-only transactions only. The transaction access mode specifies whether transactions operate in read/write or read-only mode.
*note 'TRUNCATE TABLE': truncate-table. is permitted for transaction summary tables. It has these effects:
For summary tables not aggregated by account, host, or user, truncation resets the summary columns to zero rather than removing rows.
For summary tables aggregated by account, host, or user, truncation removes rows for accounts, hosts, or users with no connections, and resets the summary columns to zero for the remaining rows.
In addition, each transaction summary table that is aggregated by account, host, user, or thread is implicitly truncated by truncation of the connection table on which it depends, or truncation of note 'events_transactions_summary_global_by_event_name': performance-schema-transaction-summary-tables. For details, see note performance-schema-connection-tables::.
Transaction Aggregation Rules
Transaction event collection occurs without regard to isolation level, access mode, or autocommit mode.
Transaction event collection occurs for all non-aborted transactions initiated by the server, including empty transactions.
Read-write transactions are generally more resource intensive than read-only transactions, therefore transaction summary tables include separate aggregate columns for read-write and read-only transactions.
Resource requirements may also vary with transaction isolation level. However, presuming that only one isolation level would be used per server, aggregation by isolation level is not provided.
File: manual.info.tmp, Node: performance-schema-objects-summary-global-by-type-table, Next: performance-schema-file-summary-tables, Prev: performance-schema-transaction-summary-tables, Up: performance-schema-summary-tables
25.12.15.5 Object Wait Summary Table ....................................
The Performance Schema maintains the *note 'objects_summary_global_by_type': performance-schema-objects-summary-global-by-type-table. table for aggregating object wait events.
Example object wait event summary information:
mysql> SELECT * FROM performance_schema.objects_summary_global_by_type\G
...
*************************** 3. row ***************************
OBJECT_TYPE: TABLE
OBJECT_SCHEMA: test
OBJECT_NAME: t
COUNT_STAR: 3
SUM_TIMER_WAIT: 263126976
MIN_TIMER_WAIT: 1522272
AVG_TIMER_WAIT: 87708678
MAX_TIMER_WAIT: 258428280
...
*************************** 10. row ***************************
OBJECT_TYPE: TABLE
OBJECT_SCHEMA: mysql
OBJECT_NAME: user
COUNT_STAR: 14
SUM_TIMER_WAIT: 365567592
MIN_TIMER_WAIT: 1141704
AVG_TIMER_WAIT: 26111769
MAX_TIMER_WAIT: 334783032
...
The *note 'objects_summary_global_by_type': performance-schema-objects-summary-global-by-type-table. table has these grouping columns to indicate how the table aggregates events: 'OBJECT_TYPE', 'OBJECT_SCHEMA', and 'OBJECT_NAME'. Each row summarizes events for the given object.
note 'objects_summary_global_by_type': performance-schema-objects-summary-global-by-type-table. has the same summary columns as the 'events_waits_summary_by_XXX' tables. See note performance-schema-wait-summary-tables::.
*note 'TRUNCATE TABLE': truncate-table. is permitted for the object summary table. It resets the summary columns to zero rather than removing rows.
File: manual.info.tmp, Node: performance-schema-file-summary-tables, Next: performance-schema-table-wait-summary-tables, Prev: performance-schema-objects-summary-global-by-type-table, Up: performance-schema-summary-tables
25.12.15.6 File I/O Summary Tables ..................................
The Performance Schema maintains file I/O summary tables that aggregate information about I/O operations.
Example file I/O event summary information:
mysql> SELECT * FROM performance_schema.file_summary_by_event_name\G
...
*************************** 2. row ***************************
EVENT_NAME: wait/io/file/sql/binlog
COUNT_STAR: 31
SUM_TIMER_WAIT: 8243784888
MIN_TIMER_WAIT: 0
AVG_TIMER_WAIT: 265928484
MAX_TIMER_WAIT: 6490658832
...
mysql> SELECT * FROM performance_schema.file_summary_by_instance\G
...
*************************** 2. row ***************************
FILE_NAME: /var/mysql/share/english/errmsg.sys
EVENT_NAME: wait/io/file/sql/ERRMSG
EVENT_NAME: wait/io/file/sql/ERRMSG
OBJECT_INSTANCE_BEGIN: 4686193384
COUNT_STAR: 5
SUM_TIMER_WAIT: 13990154448
MIN_TIMER_WAIT: 26349624
AVG_TIMER_WAIT: 2798030607
MAX_TIMER_WAIT: 8150662536
...
Each file I/O summary table has one or more grouping columns to indicate how the table aggregates events. Event names refer to names of event instruments in the *note 'setup_instruments': performance-schema-setup-instruments-table. table:
*note 'file_summary_by_event_name': performance-schema-file-summary-tables. has an 'EVENT_NAME' column. Each row summarizes events for a given event name.
*note 'file_summary_by_instance': performance-schema-file-summary-tables. has 'FILE_NAME', 'EVENT_NAME', and 'OBJECT_INSTANCE_BEGIN' columns. Each row summarizes events for a given file and event name.
Each file I/O summary table has the following summary columns containing aggregated values. Some columns are more general and have values that are the same as the sum of the values of more fine-grained columns. In this way, aggregations at higher levels are available directly without the need for user-defined views that sum lower-level columns.
'COUNT_STAR', 'SUM_TIMER_WAIT', 'MIN_TIMER_WAIT', 'AVG_TIMER_WAIT', 'MAX_TIMER_WAIT'
These columns aggregate all I/O operations.
'COUNT_READ', 'SUM_TIMER_READ', 'MIN_TIMER_READ', 'AVG_TIMER_READ', 'MAX_TIMER_READ', 'SUM_NUMBER_OF_BYTES_READ'
These columns aggregate all read operations, including 'FGETS', 'FGETC', 'FREAD', and 'READ'.
'COUNT_WRITE', 'SUM_TIMER_WRITE', 'MIN_TIMER_WRITE', 'AVG_TIMER_WRITE', 'MAX_TIMER_WRITE', 'SUM_NUMBER_OF_BYTES_WRITE'
These columns aggregate all write operations, including 'FPUTS', 'FPUTC', 'FPRINTF', 'VFPRINTF', 'FWRITE', and 'PWRITE'.
'COUNT_MISC', 'SUM_TIMER_MISC', 'MIN_TIMER_MISC', 'AVG_TIMER_MISC', 'MAX_TIMER_MISC'
These columns aggregate all other I/O operations, including 'CREATE', 'DELETE', 'OPEN', 'CLOSE', 'STREAM_OPEN', 'STREAM_CLOSE', 'SEEK', 'TELL', 'FLUSH', 'STAT', 'FSTAT', 'CHSIZE', 'RENAME', and 'SYNC'. There are no byte counts for these operations.
*note 'TRUNCATE TABLE': truncate-table. is permitted for file I/O summary tables. It resets the summary columns to zero rather than removing rows.
The MySQL server uses several techniques to avoid I/O operations by caching information read from files, so it is possible that statements you might expect to result in I/O events do not do so. You may be able to ensure that I/O does occur by flushing caches or restarting the server to reset its state.
File: manual.info.tmp, Node: performance-schema-table-wait-summary-tables, Next: performance-schema-socket-summary-tables, Prev: performance-schema-file-summary-tables, Up: performance-schema-summary-tables
25.12.15.7 Table I/O and Lock Wait Summary Tables .................................................
Menu:
performance-schema-table-lock-waits-summary-by-table-table:: The table_lock_waits_summary_by_table Table
The following sections describe the table I/O and lock wait summary tables:
*note 'table_io_waits_summary_by_index_usage': performance-schema-table-io-waits-summary-by-index-usage-table.: Table I/O waits per index
*note 'table_io_waits_summary_by_table': performance-schema-table-io-waits-summary-by-table-table.: Table I/O waits per table
*note 'table_lock_waits_summary_by_table': performance-schema-table-lock-waits-summary-by-table-table.: Table lock waits per table
File: manual.info.tmp, Node: performance-schema-table-io-waits-summary-by-table-table, Next: performance-schema-table-io-waits-summary-by-index-usage-table, Prev: performance-schema-table-wait-summary-tables, Up: performance-schema-table-wait-summary-tables
25.12.15.8 The table_io_waits_summary_by_table Table ....................................................
The *note 'table_io_waits_summary_by_table': performance-schema-table-io-waits-summary-by-table-table. table aggregates all table I/O wait events, as generated by the 'wait/io/table/sql/handler' instrument. The grouping is by table.
The note 'table_io_waits_summary_by_table': performance-schema-table-io-waits-summary-by-table-table. table has these grouping columns to indicate how the table aggregates events: 'OBJECT_TYPE', 'OBJECT_SCHEMA', and 'OBJECT_NAME'. These columns have the same meaning as in the note 'events_waits_current': performance-schema-events-waits-current-table. table. They identify the table to which the row applies.
*note 'table_io_waits_summary_by_table': performance-schema-table-io-waits-summary-by-table-table. has the following summary columns containing aggregated values. As indicated in the column descriptions, some columns are more general and have values that are the same as the sum of the values of more fine-grained columns. For example, columns that aggregate all writes hold the sum of the corresponding columns that aggregate inserts, updates, and deletes. In this way, aggregations at higher levels are available directly without the need for user-defined views that sum lower-level columns.
'COUNT_STAR', 'SUM_TIMER_WAIT', 'MIN_TIMER_WAIT', 'AVG_TIMER_WAIT', 'MAX_TIMER_WAIT'
These columns aggregate all I/O operations. They are the same as the sum of the corresponding 'XXX_READ' and 'XXX_WRITE' columns.
'COUNT_READ', 'SUM_TIMER_READ', 'MIN_TIMER_READ', 'AVG_TIMER_READ', 'MAX_TIMER_READ'
These columns aggregate all read operations. They are the same as the sum of the corresponding 'XXX_FETCH' columns.
'COUNT_WRITE', 'SUM_TIMER_WRITE', 'MIN_TIMER_WRITE', 'AVG_TIMER_WRITE', 'MAX_TIMER_WRITE'
These columns aggregate all write operations. They are the same as the sum of the corresponding 'XXX_INSERT', 'XXX_UPDATE', and 'XXX_DELETE' columns.
'COUNT_FETCH', 'SUM_TIMER_FETCH', 'MIN_TIMER_FETCH', 'AVG_TIMER_FETCH', 'MAX_TIMER_FETCH'
These columns aggregate all fetch operations.
'COUNT_INSERT', 'SUM_TIMER_INSERT', 'MIN_TIMER_INSERT', 'AVG_TIMER_INSERT', 'MAX_TIMER_INSERT'
These columns aggregate all insert operations.
'COUNT_UPDATE', 'SUM_TIMER_UPDATE', 'MIN_TIMER_UPDATE', 'AVG_TIMER_UPDATE', 'MAX_TIMER_UPDATE'
These columns aggregate all update operations.
'COUNT_DELETE', 'SUM_TIMER_DELETE', 'MIN_TIMER_DELETE', 'AVG_TIMER_DELETE', 'MAX_TIMER_DELETE'
These columns aggregate all delete operations.
note 'TRUNCATE TABLE': truncate-table. is permitted for table I/O summary tables. It resets the summary columns to zero rather than removing rows. Truncating this table also truncates the note 'table_io_waits_summary_by_index_usage': performance-schema-table-io-waits-summary-by-index-usage-table. table.
File: manual.info.tmp, Node: performance-schema-table-io-waits-summary-by-index-usage-table, Next: performance-schema-table-lock-waits-summary-by-table-table, Prev: performance-schema-table-io-waits-summary-by-table-table, Up: performance-schema-table-wait-summary-tables
25.12.15.9 The table_io_waits_summary_by_index_usage Table ..........................................................
The *note 'table_io_waits_summary_by_index_usage': performance-schema-table-io-waits-summary-by-index-usage-table. table aggregates all table index I/O wait events, as generated by the 'wait/io/table/sql/handler' instrument. The grouping is by table index.
The columns of note 'table_io_waits_summary_by_index_usage': performance-schema-table-io-waits-summary-by-index-usage-table. are nearly identical to note 'table_io_waits_summary_by_table': performance-schema-table-io-waits-summary-by-table-table. The only difference is the additional group column, 'INDEX_NAME', which corresponds to the name of the index that was used when the table I/O wait event was recorded:
A value of 'PRIMARY' indicates that table I/O used the primary index.
A value of 'NULL' means that table I/O used no index.
Inserts are counted against 'INDEX_NAME = NULL'.
note 'TRUNCATE TABLE': truncate-table. is permitted for table I/O summary tables. It resets the summary columns to zero rather than removing rows. This table is also truncated by truncation of the note 'table_io_waits_summary_by_table': performance-schema-table-io-waits-summary-by-table-table. table. A DDL operation that changes the index structure of a table may cause the per-index statistics to be reset.
File: manual.info.tmp, Node: performance-schema-table-lock-waits-summary-by-table-table, Prev: performance-schema-table-io-waits-summary-by-index-usage-table, Up: performance-schema-table-wait-summary-tables
25.12.15.10 The table_lock_waits_summary_by_table Table .......................................................
The *note 'table_lock_waits_summary_by_table': performance-schema-table-lock-waits-summary-by-table-table. table aggregates all table lock wait events, as generated by the 'wait/lock/table/sql/handler' instrument. The grouping is by table.
This table contains information about internal and external locks:
An internal lock corresponds to a lock in the SQL layer. This is currently implemented by a call to 'thr_lock()'. In event rows, these locks are distinguished by the 'OPERATION' column, which has one of these values:
read normal
read with shared locks
read high priority
read no insert
write allow write
write concurrent insert
write delayed
write low priority
write normal
An external lock corresponds to a lock in the storage engine layer. This is currently implemented by a call to 'handler::external_lock()'. In event rows, these locks are distinguished by the 'OPERATION' column, which has one of these values:
read external
write external
The note 'table_lock_waits_summary_by_table': performance-schema-table-lock-waits-summary-by-table-table. table has these grouping columns to indicate how the table aggregates events: 'OBJECT_TYPE', 'OBJECT_SCHEMA', and 'OBJECT_NAME'. These columns have the same meaning as in the note 'events_waits_current': performance-schema-events-waits-current-table. table. They identify the table to which the row applies.
*note 'table_lock_waits_summary_by_table': performance-schema-table-lock-waits-summary-by-table-table. has the following summary columns containing aggregated values. As indicated in the column descriptions, some columns are more general and have values that are the same as the sum of the values of more fine-grained columns. For example, columns that aggregate all locks hold the sum of the corresponding columns that aggregate read and write locks. In this way, aggregations at higher levels are available directly without the need for user-defined views that sum lower-level columns.
'COUNT_STAR', 'SUM_TIMER_WAIT', 'MIN_TIMER_WAIT', 'AVG_TIMER_WAIT', 'MAX_TIMER_WAIT'
These columns aggregate all lock operations. They are the same as the sum of the corresponding 'XXX_READ' and 'XXX_WRITE' columns.
'COUNT_READ', 'SUM_TIMER_READ', 'MIN_TIMER_READ', 'AVG_TIMER_READ', 'MAX_TIMER_READ'
These columns aggregate all read-lock operations. They are the same as the sum of the corresponding 'XXX_READ_NORMAL', 'XXX_READ_WITH_SHARED_LOCKS', 'XXX_READ_HIGH_PRIORITY', and 'XXX_READ_NO_INSERT' columns.
'COUNT_WRITE', 'SUM_TIMER_WRITE', 'MIN_TIMER_WRITE', 'AVG_TIMER_WRITE', 'MAX_TIMER_WRITE'
These columns aggregate all write-lock operations. They are the same as the sum of the corresponding 'XXX_WRITE_ALLOW_WRITE', 'XXX_WRITE_CONCURRENT_INSERT', 'XXX_WRITE_LOW_PRIORITY', and 'XXX_WRITE_NORMAL' columns.
'COUNT_READ_NORMAL', 'SUM_TIMER_READ_NORMAL', 'MIN_TIMER_READ_NORMAL', 'AVG_TIMER_READ_NORMAL', 'MAX_TIMER_READ_NORMAL'
These columns aggregate internal read locks.
'COUNT_READ_WITH_SHARED_LOCKS', 'SUM_TIMER_READ_WITH_SHARED_LOCKS', 'MIN_TIMER_READ_WITH_SHARED_LOCKS', 'AVG_TIMER_READ_WITH_SHARED_LOCKS', 'MAX_TIMER_READ_WITH_SHARED_LOCKS'
These columns aggregate internal read locks.
'COUNT_READ_HIGH_PRIORITY', 'SUM_TIMER_READ_HIGH_PRIORITY', 'MIN_TIMER_READ_HIGH_PRIORITY', 'AVG_TIMER_READ_HIGH_PRIORITY', 'MAX_TIMER_READ_HIGH_PRIORITY'
These columns aggregate internal read locks.
'COUNT_READ_NO_INSERT', 'SUM_TIMER_READ_NO_INSERT', 'MIN_TIMER_READ_NO_INSERT', 'AVG_TIMER_READ_NO_INSERT', 'MAX_TIMER_READ_NO_INSERT'
These columns aggregate internal read locks.
'COUNT_READ_EXTERNAL', 'SUM_TIMER_READ_EXTERNAL', 'MIN_TIMER_READ_EXTERNAL', 'AVG_TIMER_READ_EXTERNAL', 'MAX_TIMER_READ_EXTERNAL'
These columns aggregate external read locks.
'COUNT_WRITE_ALLOW_WRITE', 'SUM_TIMER_WRITE_ALLOW_WRITE', 'MIN_TIMER_WRITE_ALLOW_WRITE', 'AVG_TIMER_WRITE_ALLOW_WRITE', 'MAX_TIMER_WRITE_ALLOW_WRITE'
These columns aggregate internal write locks.
'COUNT_WRITE_CONCURRENT_INSERT', 'SUM_TIMER_WRITE_CONCURRENT_INSERT', 'MIN_TIMER_WRITE_CONCURRENT_INSERT', 'AVG_TIMER_WRITE_CONCURRENT_INSERT', 'MAX_TIMER_WRITE_CONCURRENT_INSERT'
These columns aggregate internal write locks.
'COUNT_WRITE_LOW_PRIORITY', 'SUM_TIMER_WRITE_LOW_PRIORITY', 'MIN_TIMER_WRITE_LOW_PRIORITY', 'AVG_TIMER_WRITE_LOW_PRIORITY', 'MAX_TIMER_WRITE_LOW_PRIORITY'
These columns aggregate internal write locks.
'COUNT_WRITE_NORMAL', 'SUM_TIMER_WRITE_NORMAL', 'MIN_TIMER_WRITE_NORMAL', 'AVG_TIMER_WRITE_NORMAL', 'MAX_TIMER_WRITE_NORMAL'
These columns aggregate internal write locks.
'COUNT_WRITE_EXTERNAL', 'SUM_TIMER_WRITE_EXTERNAL', 'MIN_TIMER_WRITE_EXTERNAL', 'AVG_TIMER_WRITE_EXTERNAL', 'MAX_TIMER_WRITE_EXTERNAL'
These columns aggregate external write locks.
*note 'TRUNCATE TABLE': truncate-table. is permitted for table lock summary tables. It resets the summary columns to zero rather than removing rows.
File: manual.info.tmp, Node: performance-schema-socket-summary-tables, Next: performance-schema-memory-summary-tables, Prev: performance-schema-table-wait-summary-tables, Up: performance-schema-summary-tables
25.12.15.11 Socket Summary Tables .................................
These socket summary tables aggregate timer and byte count information for socket operations:
note 'socket_summary_by_event_name': performance-schema-socket-summary-tables.: Aggregate timer and byte count statistics generated by the 'wait/io/socket/' instruments for all socket I/O operations, per socket instrument.
note 'socket_summary_by_instance': performance-schema-socket-summary-tables.: Aggregate timer and byte count statistics generated by the 'wait/io/socket/' instruments for all socket I/O operations, per socket instance. When a connection terminates, the row in *note 'socket_summary_by_instance': performance-schema-socket-summary-tables. corresponding to it is deleted.
The socket summary tables do not aggregate waits generated by 'idle' events while sockets are waiting for the next request from the client. For 'idle' event aggregations, use the wait-event summary tables; see *note performance-schema-wait-summary-tables::.
Each socket summary table has one or more grouping columns to indicate how the table aggregates events. Event names refer to names of event instruments in the *note 'setup_instruments': performance-schema-setup-instruments-table. table:
*note 'socket_summary_by_event_name': performance-schema-socket-summary-tables. has an 'EVENT_NAME' column. Each row summarizes events for a given event name.
*note 'socket_summary_by_instance': performance-schema-socket-summary-tables. has an 'OBJECT_INSTANCE_BEGIN' column. Each row summarizes events for a given object.
Each socket summary table has these summary columns containing aggregated values:
'COUNT_STAR', 'SUM_TIMER_WAIT', 'MIN_TIMER_WAIT', 'AVG_TIMER_WAIT', 'MAX_TIMER_WAIT'
These columns aggregate all operations.
'COUNT_READ', 'SUM_TIMER_READ', 'MIN_TIMER_READ', 'AVG_TIMER_READ', 'MAX_TIMER_READ', 'SUM_NUMBER_OF_BYTES_READ'
These columns aggregate all receive operations ('RECV', 'RECVFROM', and 'RECVMSG').
'COUNT_WRITE', 'SUM_TIMER_WRITE', 'MIN_TIMER_WRITE', 'AVG_TIMER_WRITE', 'MAX_TIMER_WRITE', 'SUM_NUMBER_OF_BYTES_WRITE'
These columns aggregate all send operations ('SEND', 'SENDTO', and 'SENDMSG').
'COUNT_MISC', 'SUM_TIMER_MISC', 'MIN_TIMER_MISC', 'AVG_TIMER_MISC', 'MAX_TIMER_MISC'
These columns aggregate all other socket operations, such as 'CONNECT', 'LISTEN', 'ACCEPT', 'CLOSE', and 'SHUTDOWN'. There are no byte counts for these operations.
The *note 'socket_summary_by_instance': performance-schema-socket-summary-tables. table also has an 'EVENT_NAME' column that indicates the class of the socket: 'client_connection', 'server_tcpip_socket', 'server_unix_socket'. This column can be grouped on to isolate, for example, client activity from that of the server listening sockets.
note 'TRUNCATE TABLE': truncate-table. is permitted for socket summary tables. Except for note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables, tt resets the summary columns to zero rather than removing rows.
File: manual.info.tmp, Node: performance-schema-memory-summary-tables, Next: performance-schema-status-variable-summary-tables, Prev: performance-schema-socket-summary-tables, Up: performance-schema-summary-tables
25.12.15.12 Memory Summary Tables .................................
The Performance Schema instruments memory usage and aggregates memory usage statistics, detailed by these factors:
Type of memory used (various caches, internal buffers, and so forth)
Thread, account, user, host indirectly performing the memory operation
The Performance Schema instruments the following aspects of memory use
Memory sizes used
Operation counts
Low and high water marks
Memory sizes help to understand or tune the memory consumption of the server.
Operation counts help to understand or tune the overall pressure the server is putting on the memory allocator, which has an impact on performance. Allocating a single byte one million times is not the same as allocating one million bytes a single time; tracking both sizes and counts can expose the difference.
Low and high water marks are critical to detect workload spikes, overall workload stability, and possible memory leaks.
Memory summary tables do not contain timing information because memory events are not timed.
For information about collecting memory usage data, see *note memory-instrumentation-behavior::.
Example memory event summary information:
mysql> SELECT *
FROM performance_schema.memory_summary_global_by_event_name
WHERE EVENT_NAME = 'memory/sql/TABLE'\G
*************************** 1. row ***************************
EVENT_NAME: memory/sql/TABLE
COUNT_ALLOC: 1381
COUNT_FREE: 924
SUM_NUMBER_OF_BYTES_ALLOC: 2059873
SUM_NUMBER_OF_BYTES_FREE: 1407432
LOW_COUNT_USED: 0
CURRENT_COUNT_USED: 457
HIGH_COUNT_USED: 461
LOW_NUMBER_OF_BYTES_USED: 0
CURRENT_NUMBER_OF_BYTES_USED: 652441
HIGH_NUMBER_OF_BYTES_USED: 669269
Each memory summary table has one or more grouping columns to indicate how the table aggregates events. Event names refer to names of event instruments in the *note 'setup_instruments': performance-schema-setup-instruments-table. table:
*note 'memory_summary_by_account_by_event_name': performance-schema-memory-summary-tables. has 'USER', 'HOST', and 'EVENT_NAME' columns. Each row summarizes events for a given account (user and host combination) and event name.
*note 'memory_summary_by_host_by_event_name': performance-schema-memory-summary-tables. has 'HOST' and 'EVENT_NAME' columns. Each row summarizes events for a given host and event name.
*note 'memory_summary_by_thread_by_event_name': performance-schema-memory-summary-tables. has 'THREAD_ID' and 'EVENT_NAME' columns. Each row summarizes events for a given thread and event name.
*note 'memory_summary_by_user_by_event_name': performance-schema-memory-summary-tables. has 'USER' and 'EVENT_NAME' columns. Each row summarizes events for a given user and event name.
*note 'memory_summary_global_by_event_name': performance-schema-memory-summary-tables. has an 'EVENT_NAME' column. Each row summarizes events for a given event name.
Each memory summary table has these summary columns containing aggregated values:
'COUNT_ALLOC', 'COUNT_FREE'
The aggregated numbers of calls to memory-allocation and memory-free functions.
'SUM_NUMBER_OF_BYTES_ALLOC', 'SUM_NUMBER_OF_BYTES_FREE'
The aggregated sizes of allocated and freed memory blocks.
'CURRENT_COUNT_USED'
The aggregated number of currently allocated blocks that have not been freed yet. This is a convenience column, equal to 'COUNT_ALLOC' − 'COUNT_FREE'.
'CURRENT_NUMBER_OF_BYTES_USED'
The aggregated size of currently allocated memory blocks that have not been freed yet. This is a convenience column, equal to 'SUM_NUMBER_OF_BYTES_ALLOC' − 'SUM_NUMBER_OF_BYTES_FREE'.
'LOW_COUNT_USED', 'HIGH_COUNT_USED'
The low and high water marks corresponding to the 'CURRENT_COUNT_USED' column.
'LOW_NUMBER_OF_BYTES_USED', 'HIGH_NUMBER_OF_BYTES_USED'
The low and high water marks corresponding to the 'CURRENT_NUMBER_OF_BYTES_USED' column.
*note 'TRUNCATE TABLE': truncate-table. is permitted for memory summary tables. It has these effects:
In general, truncation resets the baseline for statistics, but does not change the server state. That is, truncating a memory table does not free memory.
'COUNT_ALLOC' and 'COUNT_FREE' are reset to a new baseline, by reducing each counter by the same value.
Likewise, 'SUM_NUMBER_OF_BYTES_ALLOC' and 'SUM_NUMBER_OF_BYTES_FREE' are reset to a new baseline.
'LOW_COUNT_USED' and 'HIGH_COUNT_USED' are reset to 'CURRENT_COUNT_USED'.
'LOW_NUMBER_OF_BYTES_USED' and 'HIGH_NUMBER_OF_BYTES_USED' are reset to 'CURRENT_NUMBER_OF_BYTES_USED'.
In addition, each memory summary table that is aggregated by account, host, user, or thread is implicitly truncated by truncation of the connection table on which it depends, or truncation of note 'memory_summary_global_by_event_name': performance-schema-memory-summary-tables. For details, see note performance-schema-connection-tables::.
Memory Instrumentation Behavior
Memory instruments are listed in the *note 'setup_instruments': performance-schema-setup-instruments-table. table and have names of the form 'memory/CODE_AREA/INSTRUMENT_NAME'. Most memory instrumentation is disabled by default.
Instruments named with the prefix 'memory/performance_schema/' expose how much memory is allocated for internal buffers in the Performance Schema itself. The 'memory/performance_schema/' instruments are built in, always enabled, and cannot be disabled at startup or runtime. Built-in memory instruments are displayed only in the *note 'memory_summary_global_by_event_name': performance-schema-memory-summary-tables. table.
To control memory instrumentation state at server startup, use lines like these in your 'my.cnf' file:
Enable:
[mysqld]
performance-schema-instrument='memory/%=ON'
Disable:
[mysqld]
performance-schema-instrument='memory/%=OFF'
To control memory instrumentation state at runtime, update the 'ENABLED' column of the relevant instruments in the *note 'setup_instruments': performance-schema-setup-instruments-table. table:
Enable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES'
WHERE NAME LIKE 'memory/%';
Disable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'NO'
WHERE NAME LIKE 'memory/%';
For memory instruments, the 'TIMED' column in *note 'setup_instruments': performance-schema-setup-instruments-table. is ignored because memory operations are not timed.
When a thread in the server executes a memory allocation that has been instrumented, these rules apply:
If the thread is not instrumented or the memory instrument is not enabled, the memory block allocated is not instrumented.
Otherwise (that is, both the thread and the instrument are enabled), the memory block allocated is instrumented.
For deallocation, these rules apply:
If a memory allocation operation was instrumented, the corresponding free operation is instrumented, regardless of the current instrument or thread enabled status.
If a memory allocation operation was not instrumented, the corresponding free operation is not instrumented, regardless of the current instrument or thread enabled status.
For the per-thread statistics, the following rules apply.
When an instrumented memory block of size N is allocated, the Performance Schema makes these updates to memory summary table columns:
'COUNT_ALLOC': Increased by 1
'CURRENT_COUNT_USED': Increased by 1
'HIGH_COUNT_USED': Increased if 'CURRENT_COUNT_USED' is a new maximum
'SUM_NUMBER_OF_BYTES_ALLOC': Increased by N
'CURRENT_NUMBER_OF_BYTES_USED': Increased by N
'HIGH_NUMBER_OF_BYTES_USED': Increased if 'CURRENT_NUMBER_OF_BYTES_USED' is a new maximum
When an instrumented memory block is deallocated, the Performance Schema makes these updates to memory summary table columns:
'COUNT_FREE': Increased by 1
'CURRENT_COUNT_USED': Decreased by 1
'LOW_COUNT_USED': Decreased if 'CURRENT_COUNT_USED' is a new minimum
'SUM_NUMBER_OF_BYTES_FREE': Increased by N
'CURRENT_NUMBER_OF_BYTES_USED': Decreased by N
'LOW_NUMBER_OF_BYTES_USED': Decreased if 'CURRENT_NUMBER_OF_BYTES_USED' is a new minimum
For higher-level aggregates (global, by account, by user, by host), the same rules apply as expected for low and high water marks.
'LOW_COUNT_USED' and 'LOW_NUMBER_OF_BYTES_USED' are lower estimates. The value reported by the Performance Schema is guaranteed to be less than or equal to the lowest count or size of memory effectively used at runtime.
'HIGH_COUNT_USED' and 'HIGH_NUMBER_OF_BYTES_USED' are higher estimates. The value reported by the Performance Schema is guaranteed to be greater than or equal to the highest count or size of memory effectively used at runtime.
For lower estimates in summary tables other than *note 'memory_summary_global_by_event_name': performance-schema-memory-summary-tables, it is possible for values to go negative if memory ownership is transferred between threads.
Here is an example of estimate computation; but note that estimate implementation is subject to change:
Thread 1 uses memory in the range from 1MB to 2MB during execution, as reported by the 'LOW_NUMBER_OF_BYTES_USED' and 'HIGH_NUMBER_OF_BYTES_USED' columns of the *note 'memory_summary_by_thread_by_event_name': performance-schema-memory-summary-tables. table.
Thread 2 uses memory in the range from 10MB to 12MB during execution, as reported likewise.
When these two threads belong to the same user account, the per-account summary estimates that this account used memory in the range from 11MB to 14MB. That is, the 'LOW_NUMBER_OF_BYTES_USED' for the higher level aggregate is the sum of each 'LOW_NUMBER_OF_BYTES_USED' (assuming the worst case). Likewise, the 'HIGH_NUMBER_OF_BYTES_USED' for the higher level aggregate is the sum of each 'HIGH_NUMBER_OF_BYTES_USED' (assuming the worst case).
11MB is a lower estimate that can occur only if both threads hit the low usage mark at the same time.
14MB is a higher estimate that can occur only if both threads hit the high usage mark at the same time.
The real memory usage for this account could have been in the range from 11.5MB to 13.5MB.
For capacity planning, reporting the worst case is actually the desired behavior, as it shows what can potentially happen when sessions are uncorrelated, which is typically the case.
File: manual.info.tmp, Node: performance-schema-status-variable-summary-tables, Prev: performance-schema-memory-summary-tables, Up: performance-schema-summary-tables
25.12.15.13 Status Variable Summary Tables ..........................................
Note:
The value of the 'show_compatibility_56' system variable affects the information available from the tables described here. For details, see the description of that variable in *note server-system-variables::.
The Performance Schema makes status variable information available in the tables described in *note performance-schema-status-variable-tables::. It also makes aggregated status variable information available in summary tables, described here. Each status variable summary table has one or more grouping columns to indicate how the table aggregates status values:
*note 'status_by_account': performance-schema-status-variable-summary-tables. has 'USER', 'HOST', and 'VARIABLE_NAME' columns to summarize status variables by account.
*note 'status_by_host': performance-schema-status-variable-summary-tables. has 'HOST' and 'VARIABLE_NAME' columns to summarize status variables by the host from which clients connected.
*note 'status_by_user': performance-schema-status-variable-summary-tables. has 'USER' and 'VARIABLE_NAME' columns to summarize status variables by client user name.
Each status variable summary table has this summary column containing aggregated values:
'VARIABLE_VALUE'
The aggregated status variable value for active and terminated sessions.
The meaning of 'account' in these tables is similar to its meaning in the MySQL grant tables in the 'mysql' system database, in the sense that the term refers to a combination of user and host values. They differ in that, for grant tables, the host part of an account can be a pattern, whereas for Performance Schema tables, the host value is always a specific nonpattern host name.
Account status is collected when sessions terminate. The session status counters are added to the global status counters and the corresponding account status counters. If account statistics are not collected, the session status is added to host and user status, if host and user status are collected.
Account, host, and user statistics are not collected if the 'performance_schema_accounts_size', 'performance_schema_hosts_size', and 'performance_schema_users_size' system variables, respectively, are set to 0.
The Performance Schema supports *note 'TRUNCATE TABLE': truncate-table. for status variable summary tables as follows; in all cases, status for active sessions is unaffected:
*note 'status_by_account': performance-schema-status-variable-summary-tables.: Aggregates account status from terminated sessions to user and host status, then resets account status.
*note 'status_by_host': performance-schema-status-variable-summary-tables.: Resets aggregated host status from terminated sessions.
*note 'status_by_user': performance-schema-status-variable-summary-tables.: Resets aggregated user status from terminated sessions.
'FLUSH STATUS' adds the session status from all active sessions to the global status variables, resets the status of all active sessions, and resets account, host, and user status values aggregated from disconnected sessions.
File: manual.info.tmp, Node: performance-schema-miscellaneous-tables, Prev: performance-schema-summary-tables, Up: performance-schema-table-descriptions
Menu:
performance-schema-threads-table:: The threads Table
The following sections describe tables that do not fall into the table categories discussed in the preceding sections:
*note 'host_cache': performance-schema-host-cache-table.: Information from the internal host cache.
*note 'performance_timers': performance-schema-performance-timers-table.: Which event timers are available.
*note 'threads': performance-schema-threads-table.: Information about server threads.
File: manual.info.tmp, Node: performance-schema-host-cache-table, Next: performance-schema-performance-timers-table, Prev: performance-schema-miscellaneous-tables, Up: performance-schema-miscellaneous-tables
25.12.16.1 The host_cache Table ...............................
The MySQL server maintains an in-memory host cache that contains client host name and IP address information and is used to avoid Domain Name System (DNS) lookups. The note 'host_cache': performance-schema-host-cache-table. table exposes the contents of this cache. The 'host_cache_size' system variable controls the size of the host cache, as well as the size of the note 'host_cache': performance-schema-host-cache-table. table. For operational and configuration information about the host cache, see *note host-cache::.
Because the note 'host_cache': performance-schema-host-cache-table. table exposes the contents of the host cache, it can be examined using note 'SELECT': select. statements. This may help you diagnose the causes of connection problems. The Performance Schema must be enabled or this table is empty.
The *note 'host_cache': performance-schema-host-cache-table. table has these columns:
'IP'
The IP address of the client that connected to the server, expressed as a string.
'HOST'
The resolved DNS host name for that client IP, or 'NULL' if the name is unknown.
'HOST_VALIDATED'
Whether the IP-to-host name-to-IP DNS resolution was performed successfully for the client IP. If 'HOST_VALIDATED' is 'YES', the 'HOST' column is used as the host name corresponding to the IP so that additional calls to DNS can be avoided. While 'HOST_VALIDATED' is 'NO', DNS resolution is attempted for each connection attempt, until it eventually completes with either a valid result or a permanent error. This information enables the server to avoid caching bad or missing host names during temporary DNS failures, which would negatively affect clients forever.
'SUM_CONNECT_ERRORS'
The number of connection errors that are deemed 'blocking' (assessed against the 'max_connect_errors' system variable). Only protocol handshake errors are counted, and only for hosts that passed validation ('HOST_VALIDATED = YES').
Once 'SUM_CONNECT_ERRORS' for a given host reaches the value of 'max_connect_errors', new connections from that host are blocked. The 'SUM_CONNECT_ERRORS' value can exceed the 'max_connect_errors' value because multiple connection attempts from a host can occur simultaneously while the host is not blocked. Any or all of them can fail, independently incrementing 'SUM_CONNECT_ERRORS', possibly beyond the value of 'max_connect_errors'.
Suppose that 'max_connect_errors' is 200 and 'SUM_CONNECT_ERRORS' for a given host is 199. If 10 clients attempt to connect from that host simultaneously, none of them are blocked because 'SUM_CONNECT_ERRORS' has not reached 200. If blocking errors occur for five of the clients, 'SUM_CONNECT_ERRORS' is increased by one for each client, for a resulting 'SUM_CONNECT_ERRORS' value of 204. The other five clients succeed and are not blocked because the value of 'SUM_CONNECT_ERRORS' when their connection attempts began had not reached 200. New connections from the host that begin after 'SUM_CONNECT_ERRORS' reaches 200 are blocked.
'COUNT_HOST_BLOCKED_ERRORS'
The number of connections that were blocked because 'SUM_CONNECT_ERRORS' exceeded the value of the 'max_connect_errors' system variable.
'COUNT_NAMEINFO_TRANSIENT_ERRORS'
The number of transient errors during IP-to-host name DNS resolution.
'COUNT_NAMEINFO_PERMANENT_ERRORS'
The number of permanent errors during IP-to-host name DNS resolution.
'COUNT_FORMAT_ERRORS'
The number of host name format errors. MySQL does not perform matching of 'Host' column values in the 'mysql.user' system table against host names for which one or more of the initial components of the name are entirely numeric, such as '1.2.example.com'. The client IP address is used instead. For the rationale why this type of matching does not occur, see *note account-names::.
'COUNT_ADDRINFO_TRANSIENT_ERRORS'
The number of transient errors during host name-to-IP reverse DNS resolution.
'COUNT_ADDRINFO_PERMANENT_ERRORS'
The number of permanent errors during host name-to-IP reverse DNS resolution.
'COUNT_FCRDNS_ERRORS'
The number of forward-confirmed reverse DNS errors. These errors occur when IP-to-host name-to-IP DNS resolution produces an IP address that does not match the client originating IP address.
'COUNT_HOST_ACL_ERRORS'
The number of errors that occur because no users are permitted to connect from the client host. In such cases, the server returns 'ER_HOST_NOT_PRIVILEGED' (https://dev.mysql.com/doc/mysql-errors/5.7/en/server-error-reference.html#error_er_host_not_privileged) and does not even ask for a user name or password.
'COUNT_NO_AUTH_PLUGIN_ERRORS'
The number of errors due to requests for an unavailable authentication plugin. A plugin can be unavailable if, for example, it was never loaded or a load attempt failed.
'COUNT_AUTH_PLUGIN_ERRORS'
The number of errors reported by authentication plugins.
An authentication plugin can report different error codes to indicate the root cause of a failure. Depending on the type of error, one of these columns is incremented: 'COUNT_AUTHENTICATION_ERRORS', 'COUNT_AUTH_PLUGIN_ERRORS', 'COUNT_HANDSHAKE_ERRORS'. New return codes are an optional extension to the existing plugin API. Unknown or unexpected plugin errors are counted in the 'COUNT_AUTH_PLUGIN_ERRORS' column.
'COUNT_HANDSHAKE_ERRORS'
The number of errors detected at the wire protocol level.
'COUNT_PROXY_USER_ERRORS'
The number of errors detected when proxy user A is proxied to another user B who does not exist.
'COUNT_PROXY_USER_ACL_ERRORS'
The number of errors detected when proxy user A is proxied to another user B who does exist but for whom A does not have the 'PROXY' privilege.
'COUNT_AUTHENTICATION_ERRORS'
The number of errors caused by failed authentication.
'COUNT_SSL_ERRORS'
The number of errors due to SSL problems.
'COUNT_MAX_USER_CONNECTIONS_ERRORS'
The number of errors caused by exceeding per-user connection quotas. See *note user-resources::.
'COUNT_MAX_USER_CONNECTIONS_PER_HOUR_ERRORS'
The number of errors caused by exceeding per-user connections-per-hour quotas. See *note user-resources::.
'COUNT_DEFAULT_DATABASE_ERRORS'
The number of errors related to the default database. For example, the database does not exist or the user has no privileges to access it.
'COUNT_INIT_CONNECT_ERRORS'
The number of errors caused by execution failures of statements in the 'init_connect' system variable value.
'COUNT_LOCAL_ERRORS'
The number of errors local to the server implementation and not related to the network, authentication, or authorization. For example, out-of-memory conditions fall into this category.
'COUNT_UNKNOWN_ERRORS'
The number of other, unknown errors not accounted for by other columns in this table. This column is reserved for future use, in case new error conditions must be reported, and if preserving the backward compatibility and structure of the *note 'host_cache': performance-schema-host-cache-table. table is required.
'FIRST_SEEN'
The timestamp of the first connection attempt seen from the client in the 'IP' column.
'LAST_SEEN'
The timestamp of the most recent connection attempt seen from the client in the 'IP' column.
'FIRST_ERROR_SEEN'
The timestamp of the first error seen from the client in the 'IP' column.
'LAST_ERROR_SEEN'
The timestamp of the most recent error seen from the client in the 'IP' column.
note 'TRUNCATE TABLE': truncate-table. is permitted for the note 'host_cache': performance-schema-host-cache-table. table. It requires the 'DROP' privilege for the table. Truncating the table flushes the host cache, which has the effects described in *note host-cache-flushing::.
File: manual.info.tmp, Node: performance-schema-performance-timers-table, Next: performance-schema-processlist-table, Prev: performance-schema-host-cache-table, Up: performance-schema-miscellaneous-tables
25.12.16.2 The performance_timers Table .......................................
The *note 'performance_timers': performance-schema-performance-timers-table. table shows which event timers are available:
mysql> SELECT * FROM performance_schema.performance_timers;
+-------------+-----------------+------------------+----------------+
| TIMER_NAME | TIMER_FREQUENCY | TIMER_RESOLUTION | TIMER_OVERHEAD |
+-------------+-----------------+------------------+----------------+
| CYCLE | 2389029850 | 1 | 72 |
| NANOSECOND | 1000000000 | 1 | 112 |
| MICROSECOND | 1000000 | 1 | 136 |
| MILLISECOND | 1036 | 1 | 168 |
| TICK | 105 | 1 | 2416 |
+-------------+-----------------+------------------+----------------+
If the values associated with a given timer name are 'NULL', that timer is not supported on your platform. The rows that do not contain 'NULL' indicate which timers you can use in note 'setup_timers': performance-schema-setup-timers-table. For an explanation of how event timing occurs, see note performance-schema-timing::.
Note:
As of MySQL 5.7.21, the Performance Schema note 'setup_timers': performance-schema-setup-timers-table. table is deprecated and is removed in MySQL 8.0, as is the 'TICKS' row in the note 'performance_timers': performance-schema-performance-timers-table. table.
The *note 'performance_timers': performance-schema-performance-timers-table. table has these columns:
'TIMER_NAME'
The name by which to refer to the timer when configuring the *note 'setup_timers': performance-schema-setup-timers-table. table.
'TIMER_FREQUENCY'
The number of timer units per second. For a cycle timer, the frequency is generally related to the CPU speed. For example, on a system with a 2.4GHz processor, the 'CYCLE' may be close to'TIMER_RESOLUTION'
Indicates the number of timer units by which timer values increase. If a timer has a resolution of 10, its value increases by 10 each time.
'TIMER_OVERHEAD'
The minimal number of cycles of overhead to obtain one timing with the given timer. The Performance Schema determines this value by invoking the timer 20 times during initialization and picking the smallest value. The total overhead really is twice this amount because the instrumentation invokes the timer at the start and end of each event. The timer code is called only for timed events, so this overhead does not apply for nontimed events.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'performance_timers': performance-schema-performance-timers-table. table.
File: manual.info.tmp, Node: performance-schema-processlist-table, Next: performance-schema-threads-table, Prev: performance-schema-performance-timers-table, Up: performance-schema-miscellaneous-tables
25.12.16.3 The processlist Table ................................
Note:
The *note 'processlist': performance-schema-processlist-table. table is automatically created in the Performance Schema for new installations of MySQL 5.7.39, or higher. It is also created automatically by an upgrade.
The MySQL process list indicates the operations currently being performed by the set of threads executing within the server. The note 'processlist': performance-schema-processlist-table. table is one source of process information. For a comparison of this table with other sources, see note processlist-sources::.
The *note 'processlist': performance-schema-processlist-table. table can be queried directly. If you have the 'PROCESS' privilege, you can see all threads, even those belonging to other users. Otherwise (without the 'PROCESS' privilege), nonanonymous users have access to information about their own threads but not threads for other users, and anonymous users have no access to thread information.
Note:
If the 'performance_schema_show_processlist' system variable is enabled, the note 'processlist': performance-schema-processlist-table. table also serves as the basis for an alternative implementation underlying the note 'SHOW PROCESSLIST': show-processlist. statement. For details, see later in this section.
The *note 'processlist': performance-schema-processlist-table. table contains a row for each server process:
mysql> SELECT * FROM performance_schema.processlist\G
*************************** 1. row ***************************
ID: 5
USER: event_scheduler
HOST: localhost
DB: NULL
COMMAND: Daemon
TIME: 137
STATE: Waiting on empty queue
INFO: NULL
*************************** 2. row ***************************
ID: 9
USER: me
HOST: localhost:58812
DB: NULL
COMMAND: Sleep
TIME: 95
STATE:
INFO: NULL
*************************** 3. row ***************************
ID: 10
USER: me
HOST: localhost:58834
DB: test
COMMAND: Query
TIME: 0
STATE: executing
INFO: SELECT * FROM performance_schema.processlist
...
The *note 'processlist': performance-schema-processlist-table. table has these columns:
'ID'
The connection identifier. This is the same value displayed in the 'Id' column of the note 'SHOW PROCESSLIST': show-processlist. statement, displayed in the 'PROCESSLIST_ID' column of the Performance Schema note 'threads': performance-schema-threads-table. table, and returned by the 'CONNECTION_ID()' function within the thread.
'USER'
The MySQL user who issued the statement. A value of 'system user' refers to a nonclient thread spawned by the server to handle tasks internally, for example, a delayed-row handler thread or an I/O or SQL thread used on replica hosts. For 'system user', there is no host specified in the 'Host' column. 'unauthenticated user' refers to a thread that has become associated with a client connection but for which authentication of the client user has not yet occurred. 'event_scheduler' refers to the thread that monitors scheduled events (see *note event-scheduler::).
Note:
A 'USER' value of 'system user' is distinct from the 'SYSTEM_USER' (https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_system-user) privilege. The former designates internal threads. The latter distinguishes the system user and regular user account categories (see Account Categories (https://dev.mysql.com/doc/refman/8.0/en/account-categories.html)).
'HOST'
The host name of the client issuing the statement (except for 'system user', for which there is no host). The host name for TCP/IP connections is reported in 'HOST_NAME:CLIENT_PORT' format to make it easier to determine which client is doing what.
'DB'
The default database for the thread, or 'NULL' if none has been selected.
'COMMAND'
The type of command the thread is executing on behalf of the client, or 'Sleep' if the session is idle. For descriptions of thread commands, see note thread-information::. The value of this column corresponds to the 'COM_XXX' commands of the client/server protocol and 'Com_XXX' status variables. See note server-status-variables::
'TIME'
The time in seconds that the thread has been in its current state. For a replica SQL thread, the value is the number of seconds between the timestamp of the last replicated event and the real time of the replica host. See *note replication-threads::.
'STATE'
An action, event, or state that indicates what the thread is doing. For descriptions of 'STATE' values, see *note thread-information::.
Most states correspond to very quick operations. If a thread stays in a given state for many seconds, there might be a problem that needs to be investigated.
'INFO'
The statement the thread is executing, or 'NULL' if it is executing no statement. The statement might be the one sent to the server, or an innermost statement if the statement executes other statements. For example, if a 'CALL' statement executes a stored procedure that is executing a note 'SELECT': select. statement, the 'INFO' value shows the note 'SELECT': select. statement.
'EXECUTION_ENGINE'
The query execution engine. The value is either 'PRIMARY' or 'SECONDARY'. For use with MySQL HeatWave Service and HeatWave, where the 'PRIMARY' engine is 'InnoDB' and the 'SECONDARY' engine is HeatWave ('RAPID'). For MySQL Community Edition Server, MySQL Enterprise Edition Server (on-premise), and MySQL HeatWave Service without HeatWave, the value is always 'PRIMARY'. This column was added in MySQL 8.0.29.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'processlist': performance-schema-processlist-table. table.
As mentioned previously, if the 'performance_schema_show_processlist' system variable is enabled, the *note 'processlist': performance-schema-processlist-table. table serves as the basis for an alternative implementation of other process information sources:
The *note 'SHOW PROCESSLIST': show-processlist. statement.
The note 'mysqladmin processlist': mysqladmin. command (which uses note 'SHOW PROCESSLIST': show-processlist. statement).
The default note 'SHOW PROCESSLIST': show-processlist. implementation iterates across active threads from within the thread manager while holding a global mutex. This has negative performance consequences, particularly on busy systems. The alternative note 'SHOW PROCESSLIST': show-processlist. implementation is based on the Performance Schema *note 'processlist': performance-schema-processlist-table. table. This implementation queries active thread data from the Performance Schema rather than the thread manager and does not require a mutex.
MySQL configuration affects *note 'processlist': performance-schema-processlist-table. table contents as follows:
Minimum required configuration:
* The MySQL server must be configured and built with thread
instrumentation enabled. This is true by default; it is
controlled using the 'DISABLE_PSI_THREAD' 'CMake' option.
* The Performance Schema must be enabled at server startup.
This is true by default; it is controlled using the
'performance_schema' system variable.
With that configuration satisfied, 'performance_schema_show_processlist' enables or disables the alternative note 'SHOW PROCESSLIST': show-processlist. implementation. If the minimum configuration is not satisfied, the note 'processlist': performance-schema-processlist-table. table (and thus *note 'SHOW PROCESSLIST': show-processlist.) may not return all data.
Recommended configuration:
* To avoid having some threads ignored:
* Leave the 'performance_schema_max_thread_instances'
system variable set to its default or set it at least as
great as the 'max_connections' system variable.
* Leave the 'performance_schema_max_thread_classes' system
variable set to its default.
* To avoid having some 'STATE' column values be empty, leave the
'performance_schema_max_stage_classes' system variable set to
its default.
The default for those configuration parameters is '-1', which causes the Performance Schema to autosize them at server startup. With the parameters set as indicated, the note 'processlist': performance-schema-processlist-table. table (and thus note 'SHOW PROCESSLIST': show-processlist.) produce complete process information.
The preceding configuration parameters affect the contents of the 'processlist' table. For a given configuration, however, the *note 'processlist': performance-schema-processlist-table. contents are unaffected by the 'performance_schema_show_processlist' setting.
The alternative process list implementation does not apply to the 'INFORMATION_SCHEMA' *note 'PROCESSLIST': information-schema-processlist-table. table or the 'COM_PROCESS_INFO' command of the MySQL client/server protocol.
File: manual.info.tmp, Node: performance-schema-threads-table, Prev: performance-schema-processlist-table, Up: performance-schema-miscellaneous-tables
25.12.16.4 The threads Table ............................
The *note 'threads': performance-schema-threads-table. table contains a row for each server thread. Each row contains information about a thread and indicates whether monitoring and historical event logging are enabled for it:
mysql> SELECT * FROM performance_schema.threads\G
*************************** 1. row ***************************
THREAD_ID: 1
NAME: thread/sql/main
TYPE: BACKGROUND
PROCESSLIST_ID: NULL
PROCESSLIST_USER: NULL
PROCESSLIST_HOST: NULL
PROCESSLIST_DB: NULL
PROCESSLIST_COMMAND: NULL
PROCESSLIST_TIME: 80284
PROCESSLIST_STATE: NULL
PROCESSLIST_INFO: NULL
PARENT_THREAD_ID: NULL
ROLE: NULL
INSTRUMENTED: YES
HISTORY: YES
CONNECTION_TYPE: NULL
THREAD_OS_ID: 489803
...
*************************** 4. row ***************************
THREAD_ID: 51
NAME: thread/sql/one_connection
TYPE: FOREGROUND
PROCESSLIST_ID: 34
PROCESSLIST_USER: isabella
PROCESSLIST_HOST: localhost
PROCESSLIST_DB: performance_schema
PROCESSLIST_COMMAND: Query
PROCESSLIST_TIME: 0
PROCESSLIST_STATE: Sending data
PROCESSLIST_INFO: SELECT * FROM performance_schema.threads
PARENT_THREAD_ID: 1
ROLE: NULL
INSTRUMENTED: YES
HISTORY: YES
CONNECTION_TYPE: SSL/TLS
THREAD_OS_ID: 755399
...
When the Performance Schema initializes, it populates the *note 'threads': performance-schema-threads-table. table based on the threads in existence then. Thereafter, a new row is added each time the server creates a thread.
The 'INSTRUMENTED' and 'HISTORY' column values for new threads are determined by the contents of the note 'setup_actors': performance-schema-setup-actors-table. table. For information about how to use the note 'setup_actors': performance-schema-setup-actors-table. table to control these columns, see *note performance-schema-thread-filtering::.
Removal of rows from the note 'threads': performance-schema-threads-table. table occurs when threads end. For a thread associated with a client session, removal occurs when the session ends. If a client has auto-reconnect enabled and the session reconnects after a disconnect, the session becomes associated with a new row in the note 'threads': performance-schema-threads-table. table that has a different 'PROCESSLIST_ID' value. The initial 'INSTRUMENTED' and 'HISTORY' values for the new thread may be different from those of the original thread: The *note 'setup_actors': performance-schema-setup-actors-table. table may have changed in the meantime, and if the 'INSTRUMENTED' or 'HISTORY' value for the original thread was changed after the row was initialized, the change does not carry over to the new thread.
You can enable or disable thread monitoring (that is, whether events executed by the thread are instrumented) and historical event logging. To control the initial 'INSTRUMENTED' and 'HISTORY' values for new foreground threads, use the note 'setup_actors': performance-schema-setup-actors-table. table. To control these aspects of existing threads, set the 'INSTRUMENTED' and 'HISTORY' columns of note 'threads': performance-schema-threads-table. table rows. (For more information about the conditions under which thread monitoring and historical event logging occur, see the descriptions of the 'INSTRUMENTED' and 'HISTORY' columns.)
For a comparison of the note 'threads': performance-schema-threads-table. table columns with names having a prefix of 'PROCESSLIST_' to other process information sources, see note processlist-sources::.
Important:
For thread information sources other than the note 'threads': performance-schema-threads-table. table, information about threads for other users is shown only if the current user has the 'PROCESS' privilege. That is not true of the note 'threads': performance-schema-threads-table. table; all rows are shown to any user who has the 'SELECT' privilege for the table. Users who should not be able to see threads for other users by accessing the *note 'threads': performance-schema-threads-table. table should not be given the 'SELECT' privilege for it.
The *note 'threads': performance-schema-threads-table. table has these columns:
'THREAD_ID'
A unique thread identifier.
'NAME'
The name associated with the thread instrumentation code in the server. For example, 'thread/sql/one_connection' corresponds to the thread function in the code responsible for handling a user connection, and 'thread/sql/main' stands for the 'main()' function of the server.
'TYPE'
The thread type, either 'FOREGROUND' or 'BACKGROUND'. User connection threads are foreground threads. Threads associated with internal server activity are background threads. Examples are internal 'InnoDB' threads, 'binlog dump' threads sending information to replicas, and replication I/O and SQL threads.
'PROCESSLIST_ID'
For a foreground thread (associated with a user connection), this is the connection identifier. This is the same value displayed in the 'ID' column of the 'INFORMATION_SCHEMA' note 'PROCESSLIST': information-schema-processlist-table. table, displayed in the 'Id' column of note 'SHOW PROCESSLIST': show-processlist. output, and returned by the 'CONNECTION_ID()' function within the thread.
For a background thread (not associated with a user connection), 'PROCESSLIST_ID' is 'NULL', so the values are not unique.
'PROCESSLIST_USER'
The user associated with a foreground thread, 'NULL' for a background thread.
'PROCESSLIST_HOST'
The host name of the client associated with a foreground thread, 'NULL' for a background thread.
Unlike the 'HOST' column of the 'INFORMATION_SCHEMA' note 'PROCESSLIST': information-schema-processlist-table. table or the 'Host' column of note 'SHOW PROCESSLIST': show-processlist. output, the 'PROCESSLIST_HOST' column does not include the port number for TCP/IP connections. To obtain this information from the Performance Schema, enable the socket instrumentation (which is not enabled by default) and examine the *note 'socket_instances': performance-schema-socket-instances-table. table:
mysql> SELECT * FROM performance_schema.setup_instruments
WHERE NAME LIKE 'wait/io/socket%';
+----------------------------------------+---------+-------+
| NAME | ENABLED | TIMED |
+----------------------------------------+---------+-------+
| wait/io/socket/sql/server_tcpip_socket | NO | NO |
| wait/io/socket/sql/server_unix_socket | NO | NO |
| wait/io/socket/sql/client_connection | NO | NO |
+----------------------------------------+---------+-------+
3 rows in set (0.01 sec)
mysql> UPDATE performance_schema.setup_instruments
SET ENABLED='YES'
WHERE NAME LIKE 'wait/io/socket%';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> SELECT * FROM performance_schema.socket_instances\G
*************************** 1. row ***************************
EVENT_NAME: wait/io/socket/sql/client_connection
OBJECT_INSTANCE_BEGIN: 140612577298432
THREAD_ID: 31
SOCKET_ID: 53
IP: ::ffff:127.0.0.1
PORT: 55642
STATE: ACTIVE
...
'PROCESSLIST_DB'
The default database for the thread, or 'NULL' if none has been selected.
'PROCESSLIST_COMMAND'
For foreground threads, the type of command the thread is executing on behalf of the client, or 'Sleep' if the session is idle. For descriptions of thread commands, see note thread-information::. The value of this column corresponds to the 'COM_XXX' commands of the client/server protocol and 'Com_XXX' status variables. See note server-status-variables::
Background threads do not execute commands on behalf of clients, so this column may be 'NULL'.
'PROCESSLIST_TIME'
The time in seconds that the thread has been in its current state. For a replica SQL thread, the value is the number of seconds between the timestamp of the last replicated event and the real time of the replica host. See *note replication-threads::.
'PROCESSLIST_STATE'
An action, event, or state that indicates what the thread is doing. For descriptions of 'PROCESSLIST_STATE' values, see *note thread-information::. If the value if 'NULL', the thread may correspond to an idle client session or the work it is doing is not instrumented with stages.
Most states correspond to very quick operations. If a thread stays in a given state for many seconds, there might be a problem that bears investigation.
'PROCESSLIST_INFO'
The statement the thread is executing, or 'NULL' if it is executing no statement. The statement might be the one sent to the server, or an innermost statement if the statement executes other statements. For example, if a 'CALL' statement executes a stored procedure that is executing a note 'SELECT': select. statement, the 'PROCESSLIST_INFO' value shows the note 'SELECT': select. statement.
'PARENT_THREAD_ID'
If this thread is a subthread (spawned by another thread), this is the 'THREAD_ID' value of the spawning thread.
'ROLE'
Unused.
'INSTRUMENTED'
Whether events executed by the thread are instrumented. The value is 'YES' or 'NO'.
* For foreground threads, the initial 'INSTRUMENTED' value is
determined by whether the user account associated with the
thread matches any row in the *note 'setup_actors':
performance-schema-setup-actors-table. table. Matching is
based on the values of the 'PROCESSLIST_USER' and
'PROCESSLIST_HOST' columns.
If the thread spawns a subthread, matching occurs again for
the *note 'threads': performance-schema-threads-table. table
row created for the subthread.
* For background threads, 'INSTRUMENTED' is 'YES' by default.
*note 'setup_actors': performance-schema-setup-actors-table.
is not consulted because there is no associated user for
background threads.
* For any thread, its 'INSTRUMENTED' value can be changed during
the lifetime of the thread.
For monitoring of events executed by the thread to occur, these things must be true:
* The 'thread_instrumentation' consumer in the *note
'setup_consumers': performance-schema-setup-consumers-table.
table must be 'YES'.
* The 'threads.INSTRUMENTED' column must be 'YES'.
* Monitoring occurs only for those thread events produced from
instruments that have the 'ENABLED' column set to 'YES' in the
*note 'setup_instruments':
performance-schema-setup-instruments-table. table.
'HISTORY'
Whether to log historical events for the thread. The value is 'YES' or 'NO'.
* For foreground threads, the initial 'HISTORY' value is
determined by whether the user account associated with the
thread matches any row in the *note 'setup_actors':
performance-schema-setup-actors-table. table. Matching is
based on the values of the 'PROCESSLIST_USER' and
'PROCESSLIST_HOST' columns.
If the thread spawns a subthread, matching occurs again for
the *note 'threads': performance-schema-threads-table. table
row created for the subthread.
* For background threads, 'HISTORY' is 'YES' by default. *note
'setup_actors': performance-schema-setup-actors-table. is not
consulted because there is no associated user for background
threads.
* For any thread, its 'HISTORY' value can be changed during the
lifetime of the thread.
For historical event logging for the thread to occur, these things must be true:
* The appropriate history-related consumers in the *note
'setup_consumers': performance-schema-setup-consumers-table.
table must be enabled. For example, wait event logging in the
*note 'events_waits_history':
performance-schema-events-waits-history-table. and *note
'events_waits_history_long':
performance-schema-events-waits-history-long-table. tables
requires the corresponding 'events_waits_history' and
'events_waits_history_long' consumers to be 'YES'.
* The 'threads.HISTORY' column must be 'YES'.
* Logging occurs only for those thread events produced from
instruments that have the 'ENABLED' column set to 'YES' in the
*note 'setup_instruments':
performance-schema-setup-instruments-table. table.
'CONNECTION_TYPE'
The protocol used to establish the connection, or 'NULL' for background threads. Permitted values are 'TCP/IP' (TCP/IP connection established without encryption), 'SSL/TLS' (TCP/IP connection established with encryption), 'Socket' (Unix socket file connection), 'Named Pipe' (Windows named pipe connection), and 'Shared Memory' (Windows shared memory connection).
'THREAD_OS_ID'
The thread or task identifier as defined by the underlying operating system, if there is one:
* When a MySQL thread is associated with the same operating
system thread for its lifetime, 'THREAD_OS_ID' contains the
operating system thread ID.
* When a MySQL thread is not associated with the same operating
system thread for its lifetime, 'THREAD_OS_ID' contains
'NULL'. This is typical for user sessions when the thread
pool plugin is used (see *note thread-pool::).
For Windows, 'THREAD_OS_ID' corresponds to the thread ID visible in Process Explorer (https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx).
For Linux, 'THREAD_OS_ID' corresponds to the value of the 'gettid()' function. This value is exposed, for example, using the 'perf' or 'ps -L' commands, or in the 'proc' file system ('/proc/[PID]/task/[TID]'). For more information, see the 'perf-stat(1)', 'ps(1)', and 'proc(5)' man pages.
note 'TRUNCATE TABLE': truncate-table. is not permitted for the note 'threads': performance-schema-threads-table. table.
File: manual.info.tmp, Node: performance-schema-option-variable-reference, Next: performance-schema-options, Prev: performance-schema-table-descriptions, Up: performance-schema