26.4 sys Schema Object Reference

The *note 'sys': sys-schema. schema includes tables and triggers, views, and stored procedures and functions. The following sections provide details for each of these objects.

 File: manual.info.tmp, Node: sys-schema-object-index, Next: sys-schema-tables, Prev: sys-schema-reference, Up: sys-schema-reference

26.4.1 sys Schema Object Index

The following tables list *note 'sys': sys-schema. schema objects and provide a short description of each one.

sys Schema Tables and Triggers

Table or Trigger Description Name

*note 'sys_config': sys-sys-config.sys schema configuration options table

*note 'sys_config_insert_set_user': sys-sys-config-insert-set-user.sys_config insert trigger

*note 'sys_config_update_set_user': sys-sys-config-update-set-user.sys_config update trigger

sys Schema Views

View Name Description Deprecated

*note 'host_summary': ('x$host_summary')sys-host-summary.

Statement activity, file I/O, and connections, grouped by host

*note 'host_summary_by_file_io': ('x$host_summary_by_file_io')sys-host-summary-by-file-io.

File I/O, grouped by host

*note 'host_summary_by_file_io_type': ('x$host_summary_by_file_io_type')sys-host-summary-by-file-io-type.

File I/O, grouped by host and event type

*note 'host_summary_by_stages': ('x$host_summary_by_stages')sys-host-summary-by-stages.

Statement stages, grouped by host

*note 'host_summary_by_statement_latency': ('x$host_summary_by_statement_latency')sys-host-summary-by-statement-latency.

Statement statistics, grouped by host

*note 'host_summary_by_statement_type': ('x$host_summary_by_statement_type')sys-host-summary-by-statement-type.

Statements executed, grouped by host and statement

*note 'innodb_buffer_stats_by_schema': ('x$innodb_buffer_stats_by_schema')sys-innodb-buffer-stats-by-schema.

InnoDB buffer information, grouped by schema

*note 'innodb_buffer_stats_by_table': ('x$innodb_buffer_stats_by_table')sys-innodb-buffer-stats-by-table.

InnoDB buffer information, grouped by schema and table

*note 'innodb_lock_waits': ('x$innodb_lock_waits')sys-innodb-lock-waits.

InnoDB lock information

*note 'io_by_thread_by_latency': ('x$io_by_thread_by_latency')sys-io-by-thread-by-latency.

I/O consumers, grouped by thread

*note 'io_global_by_file_by_bytes': ('x$io_global_by_file_by_bytes')sys-io-global-by-file-by-bytes.

Global I/O consumers, grouped by file and bytes

*note 'io_global_by_file_by_latency': ('x$io_global_by_file_by_latency')sys-io-global-by-file-by-latency.

Global I/O consumers, grouped by file and latency

*note 'io_global_by_wait_by_bytes': ('x$io_global_by_wait_by_bytes')sys-io-global-by-wait-by-bytes.

Global I/O consumers, grouped by bytes

*note 'io_global_by_wait_by_latency': ('x$io_global_by_wait_by_latency')sys-io-global-by-wait-by-latency.

Global I/O consumers, grouped by latency

*note 'latest_file_io': ('x$latest_file_io')sys-latest-file-io.

Most recent I/O, grouped by file and thread

*note 'memory_by_host_by_current_bytes': ('x$memory_by_host_by_current_bytes')sys-memory-by-host-by-current-bytes.

Memory use, grouped by host

*note 'memory_by_thread_by_current_bytes': ('x$memory_by_thread_by_current_bytes')sys-memory-by-thread-by-current-bytes.

Memory use, grouped by thread

*note 'memory_by_user_by_current_bytes': ('x$memory_by_user_by_current_bytes')sys-memory-by-user-by-current-bytes.

Memory use, grouped by user

*note 'memory_global_by_current_bytes': ('x$memory_global_by_current_bytes')sys-memory-global-by-current-bytes.

Memory use, grouped by allocation type

*note 'memory_global_total': ('x$memory_global_total')sys-memory-global-total.

Total memory use

*note 'metrics': sys-metrics.

Server metrics

*note 'processlist': ('x$processlist')sys-processlist.

Processlist information

*note 'ps_check_lost_instrumentation': sys-ps-check-lost-instrumentation.

Variables that have lost instruments

*note 'schema_auto_increment_columns': sys-schema-auto-increment-columns.

AUTO_INCREMENT column information

*note 'schema_index_statistics': ('x$schema_index_statistics')sys-schema-index-statistics.

Index statistics

*note 'schema_object_overview': sys-schema-object-overview.

Types of objects within each schema

*note 'schema_redundant_indexes': sys-schema-redundant-indexes.

Duplicate or redundant indexes

*note 'schema_table_lock_waits': ('x$schema_table_lock_waits')sys-schema-table-lock-waits.

Sessions waiting for metadata locks

*note 'schema_table_statistics': ('x$schema_table_statistics')sys-schema-table-statistics.

Table statistics

*note 'schema_table_statistics_with_buffer': ('x$schema_table_statistics_with_buffer')sys-schema-table-statistics-with-buffer.

Table statistics, including InnoDB buffer pool statistics

*note 'schema_tables_with_full_table_scans': ('x$schema_tables_with_full_table_scans')sys-schema-tables-with-full-table-scans.

Tables being accessed with full scans

*note 'schema_unused_indexes': sys-schema-unused-indexes.

Indexes not in active use

*note 'session': ('x$session')sys-session.

Processlist information for user sessions

*note 'session_ssl_status': sys-session-ssl-status.

Connection SSL information

*note 'statement_analysis': ('x$statement_analysis')sys-statement-analysis.

Statement aggregate statistics

*note 'statements_with_errors_or_warnings': ('x$statements_with_errors_or_warnings')sys-statements-with-errors-or-warnings.

Statements that have produced errors or warnings

*note 'statements_with_full_table_scans': ('x$statements_with_full_table_scans')sys-statements-with-full-table-scans.

Statements that have done full table scans

*note 'statements_with_runtimes_in_95th_percentile': ('x$statements_with_runtimes_in_95th_percentile')sys-statements-with-runtimes-in-95th-percentile.

Statements with highest average runtime

*note 'statements_with_sorting': ('x$statements_with_sorting')sys-statements-with-sorting.

Statements that performed sorts

*note 'statements_with_temp_tables': ('x$statements_with_temp_tables')sys-statements-with-temp-tables.

Statements that used temporary tables

*note 'user_summary': ('x$user_summary')sys-user-summary.

User statement and connection activity

*note 'user_summary_by_file_io': ('x$user_summary_by_file_io')sys-user-summary-by-file-io.

File I/O, grouped by user

*note 'user_summary_by_file_io_type': ('x$user_summary_by_file_io_type')sys-user-summary-by-file-io-type.

File I/O, grouped by user and event

*note 'user_summary_by_stages': ('x$user_summary_by_stages')sys-user-summary-by-stages.

Stage events, grouped by user

*note 'user_summary_by_statement_latency': ('x$user_summary_by_statement_latency')sys-user-summary-by-statement-latency.

Statement statistics, grouped by user

*note 'user_summary_by_statement_type': ('x$user_summary_by_statement_type')sys-user-summary-by-statement-type.

Statements executed, grouped by user and statement

*note 'version': sys-version.

Current sys 5.7.28 schema and MySQL
server versions

*note 'wait_classes_global_by_avg_latency': ('x$wait_classes_global_by_avg_latency')sys-wait-classes-global-by-avg-latency.

Wait class average latency, grouped by event class

*note 'wait_classes_global_by_latency': ('x$wait_classes_global_by_latency')sys-wait-classes-global-by-latency.

Wait class total latency, grouped by event class

*note 'waits_by_host_by_latency': ('x$waits_by_host_by_latency')sys-waits-by-host-by-latency.

Wait events, grouped by host and event

*note 'waits_by_user_by_latency': ('x$waits_by_user_by_latency')sys-waits-by-user-by-latency.

Wait events, grouped by user and event

*note 'waits_global_by_latency': ('x$waits_global_by_latency')sys-waits-global-by-latency.

Wait events, grouped by event

*note 'x$ps_digest_95th_percentile_by_avg_us': sys-statements-with-runtimes-in-95th-percentile.

Helper view for 95th-percentile views

*note 'x$ps_digest_avg_latency_distribution': sys-statements-with-runtimes-in-95th-percentile.

Helper view for 95th-percentile views

*note 'x$ps_schema_table_statistics_io': sys-schema-table-statistics.

Helper view for table-statistics views

*note 'x$schema_flattened_keys': sys-schema-redundant-indexes.

Helper view for schema_redundant_indexes

sys Schema Stored Procedures

Procedure Name Description

*note 'create_synonym_db()': sys-create-synonym-db.Create synonym for schema

*note 'diagnostics()': sys-diagnostics.Collect system diagnostic information

*note 'execute_prepared_stmt()': sys-execute-prepared-stmt.Execute prepared statement

*note 'ps_setup_disable_background_threads()': sys-ps-setup-disable-background-threads.Disable background thread instrumentation

*note 'ps_setup_disable_consumer()': sys-ps-setup-disable-consumer.Disable consumers

*note 'ps_setup_disable_instrument()': sys-ps-setup-disable-instrument.Disable instruments

*note 'ps_setup_disable_thread()': sys-ps-setup-disable-thread.Disable instrumentation for thread

*note 'ps_setup_enable_background_threads()': sys-ps-setup-enable-background-threads.Enable background thread instrumentation

*note 'ps_setup_enable_consumer()': sys-ps-setup-enable-consumer.Enable consumers

*note 'ps_setup_enable_instrument()': sys-ps-setup-enable-instrument.Enable instruments

*note 'ps_setup_enable_thread()': sys-ps-setup-enable-thread.Enable instrumentation for thread

*note 'ps_setup_reload_saved()': sys-ps-setup-reload-saved.Reload saved Performance Schema configuration

*note 'ps_setup_reset_to_default()': sys-ps-setup-reset-to-default.Reset saved Performance Schema configuration

*note 'ps_setup_save()': sys-ps-setup-save.Save Performance Schema configuration

*note 'ps_setup_show_disabled()': sys-ps-setup-show-disabled.Display disabled Performance Schema configuration

*note 'ps_setup_show_disabled_consumers()': sys-ps-setup-show-disabled-consumers.Display disabled Performance Schema consumers

*note 'ps_setup_show_disabled_instruments()': sys-ps-setup-show-disabled-instruments.Display disabled Performance Schema instruments

*note 'ps_setup_show_enabled()': sys-ps-setup-show-enabled.Display enabled Performance Schema configuration

*note 'ps_setup_show_enabled_consumers()': sys-ps-setup-show-enabled-consumers.Display enabled Performance Schema consumers

*note 'ps_setup_show_enabled_instruments()': sys-ps-setup-show-enabled-instruments.Display enabled Performance Schema instruments

*note 'ps_statement_avg_latency_histogram()': sys-ps-statement-avg-latency-histogram.Display statement latency histogram

*note 'ps_trace_statement_digest()': sys-ps-trace-statement-digest.Trace Performance Schema instrumentation for digest

*note 'ps_trace_thread()': sys-ps-trace-thread.Dump Performance Schema data for thread

*note 'ps_truncate_all_tables()': sys-ps-truncate-all-tables.Truncate Performance Schema summary tables

*note 'statement_performance_analyzer()': sys-statement-performance-analyzer.Report of statements running on server

*note 'table_exists()': sys-table-exists.Whether a table exists

sys Schema Stored Functions

Function Name Description Introduced

*note 'extract_schema_from_file_name()': sys-extract-schema-from-file-name.

Extract schema name part of file name

*note 'extract_table_from_file_name()': sys-extract-table-from-file-name.

Extract table name part of file name

*note 'format_bytes()': sys-format-bytes.

Convert byte count to value with units

*note 'format_path()': sys-format-path.

Replace directories in path name with symbolic system variable names

*note 'format_statement()': sys-format-statement.

Truncate long statement to fixed length

*note 'format_time()': sys-format-time.

Convert picoseconds time to value with units

*note 'list_add()': sys-list-add.

Add item to list

*note 'list_drop()': sys-list-drop.

Remove item from list

*note 'ps_is_account_enabled()': sys-ps-is-account-enabled.

Whether Performance Schema instrumentation for account is enabled

*note 'ps_is_consumer_enabled()': sys-ps-is-consumer-enabled.

Whether Performance Schema consumer is enabled

*note 'ps_is_instrument_default_enabled()': sys-ps-is-instrument-default-enabled.

Whether Performance Schema instrument is enabled by default

*note 'ps_is_instrument_default_timed()': sys-ps-is-instrument-default-timed.

Whether Performance Schema instrument is timed by default

*note 'ps_is_thread_instrumented()': sys-ps-is-thread-instrumented.

Whether Performance Schema instrumentation for connection ID is enabled

*note 'ps_thread_account()': sys-ps-thread-account.

Account associated with Performance Schema thread ID

*note 'ps_thread_id()': sys-ps-thread-id.

Performance Schema thread ID associated with connection ID

*note 'ps_thread_stack()': sys-ps-thread-stack.

Event information for connection ID

*note 'ps_thread_trx_info()': sys-ps-thread-trx-info.

Transaction information for thread ID

*note 'quote_identifier()': sys-quote-identifier.

Quote string as 5.7.14 identifier

*note 'sys_get_config()': sys-sys-get-config.

sys schema configuration option value

*note 'version_major()': sys-version-major.

MySQL server major version number

*note 'version_minor()': sys-version-minor.

MySQL server minor version number

*note 'version_patch()': sys-version-patch.

MySQL server patch release version number

 File: manual.info.tmp, Node: sys-schema-tables, Next: sys-schema-views, Prev: sys-schema-object-index, Up: sys-schema-reference

26.4.2 sys Schema Tables and Triggers

The following sections describe *note 'sys': sys-schema. schema tables and triggers.

 File: manual.info.tmp, Node: sys-sys-config, Next: sys-sys-config-insert-set-user, Prev: sys-schema-tables, Up: sys-schema-tables

26.4.2.1 The sys_config Table .............................

This table contains *note 'sys': sys-schema. schema configuration options, one row per option. Configuration changes made by updating this table persist across client sessions and server restarts.

The *note 'sys_config': sys-sys-config. table has these columns:

As an efficiency measure to minimize the number of direct reads from the note 'sys_config': sys-sys-config. table, note 'sys': sys-schema. schema functions that use a value from this table check for a user-defined variable with a corresponding name, which is the user-defined variable having the same name plus a '@sys.' prefix. (For example, the variable corresponding to the 'diagnostics.include_raw' option is '@sys.diagnostics.include_raw'.) If the user-defined variable exists in the current session and is non-'NULL', the function uses its value in preference to the value in the *note 'sys_config': sys-sys-config. table. Otherwise, the function reads and uses the value from the table. In the latter case, the calling function conventionally also sets the corresponding user-defined variable to the table value so that further references to the configuration option within the same session use the variable and need not read the table again.

For example, the 'statement_truncate_len' option controls the maximum length of statements returned by the *note 'format_statement()': sys-format-statement. function. The default is 64. To temporarily change the value to 32 for your current session, set the corresponding '@sys.statement_truncate_len' user-defined variable:

 mysql> SET @stmt = 'SELECT variable, value, set_time, set_by FROM sys_config';
 mysql> SELECT sys.format_statement(@stmt);
 +----------------------------------------------------------+
 | sys.format_statement(@stmt)                              |
 +----------------------------------------------------------+
 | SELECT variable, value, set_time, set_by FROM sys_config |
 +----------------------------------------------------------+
 mysql> SET @sys.statement_truncate_len = 32;
 mysql> SELECT sys.format_statement(@stmt);
 +-----------------------------------+
 | sys.format_statement(@stmt)       |
 +-----------------------------------+
 | SELECT variabl ... ROM sys_config |
 +-----------------------------------+

Subsequent invocations of *note 'format_statement()': sys-format-statement. within the session continue to use the user-defined variable value (32), rather than the value stored in the table (64).

To stop using the user-defined variable and revert to using the value in the table, set the variable to 'NULL' within your session:

 mysql> SET @sys.statement_truncate_len = NULL;
 mysql> SELECT sys.format_statement(@stmt);
 +----------------------------------------------------------+
 | sys.format_statement(@stmt)                              |
 +----------------------------------------------------------+
 | SELECT variable, value, set_time, set_by FROM sys_config |
 +----------------------------------------------------------+

Alternatively, end your current session (causing the user-defined variable to no longer exist) and begin a new session.

The conventional relationship just described between options in the *note 'sys_config': sys-sys-config. table and user-defined variables can be exploited to make temporary configuration changes that end when your session ends. However, if you set a user-defined variable and then subsequently change the corresponding table value within the same session, the changed table value is not used in that session as long as the user-defined variable exists and is not 'NULL'. (The changed table value is used in other sessions that do not have the user-defined variable assigned.)

The following list describes the options in the *note 'sys_config': sys-sys-config. table and the corresponding user-defined variables:

Other options can be added to the note 'sys_config': sys-sys-config. table. For example, the note 'diagnostics()': sys-diagnostics. and note 'execute_prepared_stmt()': sys-execute-prepared-stmt. procedures use the 'debug' option if it exists, but this option is not part of the note 'sys_config': sys-sys-config. table by default because debug output normally is enabled only temporarily, by setting the corresponding '@sys.debug' user-defined variable. To enable debug output without having to set that variable in individual sessions, add the option to the table:

 mysql> INSERT INTO sys.sys_config (variable, value) VALUES('debug', 'ON');

To change the debug setting in the table, do two things. First, modify the value in the table itself:

 mysql> UPDATE sys.sys_config
        SET value = 'OFF'
        WHERE variable = 'debug';

Second, to also ensure that procedure invocations within the current session use the changed value from the table, set the corresponding user-defined variable to 'NULL':

 mysql> SET @sys.debug = NULL;

 File: manual.info.tmp, Node: sys-sys-config-insert-set-user, Next: sys-sys-config-update-set-user, Prev: sys-sys-config, Up: sys-schema-tables

26.4.2.2 The sys_config_insert_set_user Trigger ...............................................

For rows added to the note 'sys_config': sys-sys-config. table by 'INSERT' statements, the note 'sys_config_insert_set_user': sys-sys-config-insert-set-user. trigger sets the 'set_by' column to the current user.

 File: manual.info.tmp, Node: sys-sys-config-update-set-user, Prev: sys-sys-config-insert-set-user, Up: sys-schema-tables

26.4.2.3 The sys_config_update_set_user Trigger ...............................................

The note 'sys_config_update_set_user': sys-sys-config-update-set-user. trigger for the note 'sys_config': sys-sys-config. table is similar to the note 'sys_config_insert_set_user': sys-sys-config-insert-set-user. trigger, but for note 'UPDATE': update. statements.

 File: manual.info.tmp, Node: sys-schema-views, Next: sys-schema-procedures, Prev: sys-schema-tables, Up: sys-schema-reference

26.4.3 sys Schema Views

The following sections describe *note 'sys': sys-schema. schema views.

The 'sys' schema contains many views that summarize Performance Schema tables in various ways. Most of these views come in pairs, such that one member of the pair has the same name as the other member, plus a 'x$' prefix. For example, the *note 'host_summary_by_file_io': sys-host-summary-by-file-io. view summarizes file I/O grouped by host and displays latencies converted from picoseconds to more readable values (with units);

 mysql> SELECT * FROM sys.host_summary_by_file_io;
 +------------+-------+------------+
 | host       | ios   | io_latency |
 +------------+-------+------------+
 | localhost  | 67570 | 5.38 s     |
 | background |  3468 | 4.18 s     |
 +------------+-------+------------+

The *note 'x$host_summary_by_file_io': sys-host-summary-by-file-io. view summarizes the same data but displays unformatted picosecond latencies:

 mysql> SELECT * FROM sys.x$host_summary_by_file_io;
 +------------+-------+---------------+
 | host       | ios   | io_latency    |
 +------------+-------+---------------+
 | localhost  | 67574 | 5380678125144 |
 | background |  3474 | 4758696829416 |
 +------------+-------+---------------+

The view without the 'xprefixisintendedtoprovideoutputthatismoreuserfriendlyandeasiertoread.Theviewwiththex' prefix that displays the same values in raw form is intended more for use with other tools that perform their own processing on the data.

Views without the 'xprefixdifferfromthecorrespondingx' views in these ways:

 File: manual.info.tmp, Node: sys-host-summary, Next: sys-host-summary-by-file-io, Prev: sys-schema-views, Up: sys-schema-views

26.4.3.1 The host_summary and x$host_summary Views ..................................................

These views summarize statement activity, file I/O, and connections, grouped by host.

The note 'host_summary': sys-host-summary. and note 'x$host_summary': sys-host-summary. views have these columns:

 File: manual.info.tmp, Node: sys-host-summary-by-file-io, Next: sys-host-summary-by-file-io-type, Prev: sys-host-summary, Up: sys-schema-views

26.4.3.2 The host_summary_by_file_io and x$host_summary_by_file_io Views ........................................................................

These views summarize file I/O, grouped by host. By default, rows are sorted by descending total file I/O latency.

The note 'host_summary_by_file_io': sys-host-summary-by-file-io. and note 'x$host_summary_by_file_io': sys-host-summary-by-file-io. views have these columns:

 File: manual.info.tmp, Node: sys-host-summary-by-file-io-type, Next: sys-host-summary-by-stages, Prev: sys-host-summary-by-file-io, Up: sys-schema-views

26.4.3.3 The host_summary_by_file_io_type and x$host_summary_by_file_io_type Views ..................................................................................

These views summarize file I/O, grouped by host and event type. By default, rows are sorted by host and descending total I/O latency.

The note 'host_summary_by_file_io_type': sys-host-summary-by-file-io-type. and note 'x$host_summary_by_file_io_type': sys-host-summary-by-file-io-type. views have these columns:

 File: manual.info.tmp, Node: sys-host-summary-by-stages, Next: sys-host-summary-by-statement-latency, Prev: sys-host-summary-by-file-io-type, Up: sys-schema-views

26.4.3.4 The host_summary_by_stages and x$host_summary_by_stages Views ......................................................................

These views summarize statement stages, grouped by host. By default, rows are sorted by host and descending total latency.

The note 'host_summary_by_stages': sys-host-summary-by-stages. and note 'x$host_summary_by_stages': sys-host-summary-by-stages. views have these columns:

 File: manual.info.tmp, Node: sys-host-summary-by-statement-latency, Next: sys-host-summary-by-statement-type, Prev: sys-host-summary-by-stages, Up: sys-schema-views

26.4.3.5 The host_summary_by_statement_latency and x$host_summary_by_statement_latency Views ............................................................................................

These views summarize overall statement statistics, grouped by host. By default, rows are sorted by descending total latency.

The note 'host_summary_by_statement_latency': sys-host-summary-by-statement-latency. and note 'x$host_summary_by_statement_latency': sys-host-summary-by-statement-latency. views have these columns:

 File: manual.info.tmp, Node: sys-host-summary-by-statement-type, Next: sys-innodb-buffer-stats-by-schema, Prev: sys-host-summary-by-statement-latency, Up: sys-schema-views

26.4.3.6 The host_summary_by_statement_type and x$host_summary_by_statement_type Views ......................................................................................

These views summarize informaion about statements executed, grouped by host and statement type. By default, rows are sorted by host and descending total latency.

The note 'host_summary_by_statement_type': sys-host-summary-by-statement-type. and note 'x$host_summary_by_statement_type': sys-host-summary-by-statement-type. views have these columns:

 File: manual.info.tmp, Node: sys-innodb-buffer-stats-by-schema, Next: sys-innodb-buffer-stats-by-table, Prev: sys-host-summary-by-statement-type, Up: sys-schema-views

26.4.3.7 The innodb_buffer_stats_by_schema and x$innodb_buffer_stats_by_schema Views ....................................................................................

These views summarize the information in the 'INFORMATION_SCHEMA' *note 'INNODB_BUFFER_PAGE': information-schema-innodb-buffer-page-table. table, grouped by schema. By default, rows are sorted by descending buffer size.

Warning:

Querying views that access the *note 'INNODB_BUFFER_PAGE': information-schema-innodb-buffer-page-table. table can affect performance. Do not query these views on a production system unless you are aware of the performance impact and have determined it to be acceptable. To avoid impacting performance on a production system, reproduce the issue you want to investigate and query buffer pool statistics on a test instance.

The note 'innodb_buffer_stats_by_schema': sys-innodb-buffer-stats-by-schema. and note 'x$innodb_buffer_stats_by_schema': sys-innodb-buffer-stats-by-schema. views have these columns:

 File: manual.info.tmp, Node: sys-innodb-buffer-stats-by-table, Next: sys-innodb-lock-waits, Prev: sys-innodb-buffer-stats-by-schema, Up: sys-schema-views

26.4.3.8 The innodb_buffer_stats_by_table and x$innodb_buffer_stats_by_table Views ..................................................................................

These views summarize the information in the 'INFORMATION_SCHEMA' *note 'INNODB_BUFFER_PAGE': information-schema-innodb-buffer-page-table. table, grouped by schema and table. By default, rows are sorted by descending buffer size.

Warning:

Querying views that access the *note 'INNODB_BUFFER_PAGE': information-schema-innodb-buffer-page-table. table can affect performance. Do not query these views on a production system unless you are aware of the performance impact and have determined it to be acceptable. To avoid impacting performance on a production system, reproduce the issue you want to investigate and query buffer pool statistics on a test instance.

The note 'innodb_buffer_stats_by_table': sys-innodb-buffer-stats-by-table. and note 'x$innodb_buffer_stats_by_table': sys-innodb-buffer-stats-by-table. views have these columns:

 File: manual.info.tmp, Node: sys-innodb-lock-waits, Next: sys-io-by-thread-by-latency, Prev: sys-innodb-buffer-stats-by-table, Up: sys-schema-views

26.4.3.9 The innodb_lock_waits and x$innodb_lock_waits Views ............................................................

These views summarize the 'InnoDB' locks that transactions are waiting for. By default, rows are sorted by descending lock age.

The note 'innodb_lock_waits': sys-innodb-lock-waits. and note 'x$innodb_lock_waits': sys-innodb-lock-waits. views have these columns:

 File: manual.info.tmp, Node: sys-io-by-thread-by-latency, Next: sys-io-global-by-file-by-bytes, Prev: sys-innodb-lock-waits, Up: sys-schema-views

26.4.3.10 The io_by_thread_by_latency and x$io_by_thread_by_latency Views .........................................................................

These views summarize I/O consumers to display time waiting for I/O, grouped by thread. By default, rows are sorted by descending total I/O latency.

The note 'io_by_thread_by_latency': sys-io-by-thread-by-latency. and note 'x$io_by_thread_by_latency': sys-io-by-thread-by-latency. views have these columns:

 File: manual.info.tmp, Node: sys-io-global-by-file-by-bytes, Next: sys-io-global-by-file-by-latency, Prev: sys-io-by-thread-by-latency, Up: sys-schema-views

26.4.3.11 The io_global_by_file_by_bytes and x$io_global_by_file_by_bytes Views ...............................................................................

These views summarize global I/O consumers to display amount of I/O, grouped by file. By default, rows are sorted by descending total I/O (bytes read and written).

The note 'io_global_by_file_by_bytes': sys-io-global-by-file-by-bytes. and note 'x$io_global_by_file_by_bytes': sys-io-global-by-file-by-bytes. views have these columns:

 File: manual.info.tmp, Node: sys-io-global-by-file-by-latency, Next: sys-io-global-by-wait-by-bytes, Prev: sys-io-global-by-file-by-bytes, Up: sys-schema-views

26.4.3.12 The io_global_by_file_by_latency and x$io_global_by_file_by_latency Views ...................................................................................

These views summarize global I/O consumers to display time waiting for I/O, grouped by file. By default, rows are sorted by descending total latency.

The note 'io_global_by_file_by_latency': sys-io-global-by-file-by-latency. and note 'x$io_global_by_file_by_latency': sys-io-global-by-file-by-latency. views have these columns:

 File: manual.info.tmp, Node: sys-io-global-by-wait-by-bytes, Next: sys-io-global-by-wait-by-latency, Prev: sys-io-global-by-file-by-latency, Up: sys-schema-views

26.4.3.13 The io_global_by_wait_by_bytes and x$io_global_by_wait_by_bytes Views ...............................................................................

These views summarize global I/O consumers to display amount of I/O and time waiting for I/O, grouped by event. By default, rows are sorted by descending total I/O (bytes read and written).

The note 'io_global_by_wait_by_bytes': sys-io-global-by-wait-by-bytes. and note 'x$io_global_by_wait_by_bytes': sys-io-global-by-wait-by-bytes. views have these columns:

 File: manual.info.tmp, Node: sys-io-global-by-wait-by-latency, Next: sys-latest-file-io, Prev: sys-io-global-by-wait-by-bytes, Up: sys-schema-views

26.4.3.14 The io_global_by_wait_by_latency and x$io_global_by_wait_by_latency Views ...................................................................................

These views summarize global I/O consumers to display amount of I/O and time waiting for I/O, grouped by event. By default, rows are sorted by descending total latency.

The note 'io_global_by_wait_by_latency': sys-io-global-by-wait-by-latency. and note 'x$io_global_by_wait_by_latency': sys-io-global-by-wait-by-latency. views have these columns:

 File: manual.info.tmp, Node: sys-latest-file-io, Next: sys-memory-by-host-by-current-bytes, Prev: sys-io-global-by-wait-by-latency, Up: sys-schema-views

26.4.3.15 The latest_file_io and x$latest_file_io Views .......................................................

These views summarize file I/O activity, grouped by file and thread. By default, rows are sorted with most recent I/O first.

The note 'latest_file_io': sys-latest-file-io. and note 'x$latest_file_io': sys-latest-file-io. views have these columns:

 File: manual.info.tmp, Node: sys-memory-by-host-by-current-bytes, Next: sys-memory-by-thread-by-current-bytes, Prev: sys-latest-file-io, Up: sys-schema-views

26.4.3.16 The memory_by_host_by_current_bytes and x$memory_by_host_by_current_bytes Views .........................................................................................

These views summarize memory use, grouped by host. By default, rows are sorted by descending amount of memory used.

The note 'memory_by_host_by_current_bytes': sys-memory-by-host-by-current-bytes. and note 'x$memory_by_host_by_current_bytes': sys-memory-by-host-by-current-bytes. views have these columns:

 File: manual.info.tmp, Node: sys-memory-by-thread-by-current-bytes, Next: sys-memory-by-user-by-current-bytes, Prev: sys-memory-by-host-by-current-bytes, Up: sys-schema-views

26.4.3.17 The memory_by_thread_by_current_bytes and x$memory_by_thread_by_current_bytes Views .............................................................................................

These views summarize memory use, grouped by thread. By default, rows are sorted by descending amount of memory used.

The note 'memory_by_thread_by_current_bytes': sys-memory-by-thread-by-current-bytes. and note 'x$memory_by_thread_by_current_bytes': sys-memory-by-thread-by-current-bytes. views have these columns:

 File: manual.info.tmp, Node: sys-memory-by-user-by-current-bytes, Next: sys-memory-global-by-current-bytes, Prev: sys-memory-by-thread-by-current-bytes, Up: sys-schema-views

26.4.3.18 The memory_by_user_by_current_bytes and x$memory_by_user_by_current_bytes Views .........................................................................................

These views summarize memory use, grouped by user. By default, rows are sorted by descending amount of memory used.

The note 'memory_by_user_by_current_bytes': sys-memory-by-user-by-current-bytes. and note 'x$memory_by_user_by_current_bytes': sys-memory-by-user-by-current-bytes. views have these columns:

 File: manual.info.tmp, Node: sys-memory-global-by-current-bytes, Next: sys-memory-global-total, Prev: sys-memory-by-user-by-current-bytes, Up: sys-schema-views

26.4.3.19 The memory_global_by_current_bytes and x$memory_global_by_current_bytes Views .......................................................................................

These views summarize memory use, grouped by allocation type (that is, by event). By default, rows are sorted by descending amount of memory used.

The note 'memory_global_by_current_bytes': sys-memory-global-by-current-bytes. and note 'x$memory_global_by_current_bytes': sys-memory-global-by-current-bytes. views have these columns:

 File: manual.info.tmp, Node: sys-memory-global-total, Next: sys-metrics, Prev: sys-memory-global-by-current-bytes, Up: sys-schema-views

26.4.3.20 The memory_global_total and x$memory_global_total Views .................................................................

These views summarize total memory use within the server.

The note 'memory_global_total': sys-memory-global-total. and note 'x$memory_global_total': sys-memory-global-total. views have these columns:

 File: manual.info.tmp, Node: sys-metrics, Next: sys-processlist, Prev: sys-memory-global-total, Up: sys-schema-views

26.4.3.21 The metrics View ..........................

This view summarizes MySQL server metrics to show variable names, values, types, and whether they are enabled. By default, rows are sorted by variable type and name.

The *note 'metrics': sys-metrics. view includes this information:

There is some duplication of information between the note 'global_status': performance-schema-status-variable-tables. and note 'INNODB_METRICS': information-schema-innodb-metrics-table. tables, which the *note 'metrics': sys-metrics. view eliminates.

The *note 'metrics': sys-metrics. view has these columns:

 File: manual.info.tmp, Node: sys-processlist, Next: sys-ps-check-lost-instrumentation, Prev: sys-metrics, Up: sys-schema-views

26.4.3.22 The processlist and x$processlist Views .................................................

The MySQL process list indicates the operations currently being performed by the set of threads executing within the server. The note 'processlist': sys-processlist. and note 'x$processlist': sys-processlist. views summarize process information. They provide more complete information than the note 'SHOW PROCESSLIST': show-processlist. statement and the 'INFORMATION_SCHEMA' note 'PROCESSLIST': information-schema-processlist-table. table, and are also nonblocking. By default, rows are sorted by descending process time and descending wait time. For a comparison of process information sources, see *note processlist-sources::.

The column descriptions here are brief. For additional information, see the description of the Performance Schema note 'threads': performance-schema-threads-table. table at note performance-schema-threads-table::.

The note 'processlist': sys-processlist. and note 'x$processlist': sys-processlist. views have these columns:

 File: manual.info.tmp, Node: sys-ps-check-lost-instrumentation, Next: sys-schema-auto-increment-columns, Prev: sys-processlist, Up: sys-schema-views

26.4.3.23 The ps_check_lost_instrumentation View ................................................

This view returns information about lost Performance Schema instruments, to indicate whether the Performance Schema is unable to monitor all runtime data.

The *note 'ps_check_lost_instrumentation': sys-ps-check-lost-instrumentation. view has these columns:

 File: manual.info.tmp, Node: sys-schema-auto-increment-columns, Next: sys-schema-index-statistics, Prev: sys-ps-check-lost-instrumentation, Up: sys-schema-views

26.4.3.24 The schema_auto_increment_columns View ................................................

This view indicates which tables have 'AUTO_INCREMENT' columns and provides information about those columns, such as the current and maximum column values and the usage ratio (ratio of used to possible values). By default, rows are sorted by descending usage ratio and maximum column value.

Tables in these schemas are excluded from view output: 'mysql', 'sys', 'INFORMATION_SCHEMA', 'performance_schema'.

The *note 'schema_auto_increment_columns': sys-schema-auto-increment-columns. view has these columns:

 File: manual.info.tmp, Node: sys-schema-index-statistics, Next: sys-schema-object-overview, Prev: sys-schema-auto-increment-columns, Up: sys-schema-views

26.4.3.25 The schema_index_statistics and x$schema_index_statistics Views .........................................................................

These views provide index statistics. By default, rows are sorted by descending total index latency.

The note 'schema_index_statistics': sys-schema-index-statistics. and note 'x$schema_index_statistics': sys-schema-index-statistics. views have these columns:

 File: manual.info.tmp, Node: sys-schema-object-overview, Next: sys-schema-redundant-indexes, Prev: sys-schema-index-statistics, Up: sys-schema-views

26.4.3.26 The schema_object_overview View .........................................

This view summarizes the types of objects within each schema. By default, rows are sorted by schema and object type.

Note:

For MySQL instances with a large number of objects, this view might take a long time to execute.

The *note 'schema_object_overview': sys-schema-object-overview. view has these columns:

 File: manual.info.tmp, Node: sys-schema-redundant-indexes, Next: sys-schema-table-lock-waits, Prev: sys-schema-object-overview, Up: sys-schema-views

26.4.3.27 The schema_redundant_indexes and x$schema_flattened_keys Views ........................................................................

The note 'schema_redundant_indexes': sys-schema-redundant-indexes. view displays indexes that duplicate other indexes or are made redundant by them. The note 'x$schema_flattened_keys': sys-schema-redundant-indexes. view is a helper view for *note 'schema_redundant_indexes': sys-schema-redundant-indexes.

In the following column descriptions, the dominant index is the one that makes the redundant index redundant.

The *note 'schema_redundant_indexes': sys-schema-redundant-indexes. view has these columns:

The *note 'x$schema_flattened_keys': sys-schema-redundant-indexes. view has these columns:

 File: manual.info.tmp, Node: sys-schema-table-lock-waits, Next: sys-schema-table-statistics, Prev: sys-schema-redundant-indexes, Up: sys-schema-views

26.4.3.28 The schema_table_lock_waits and x$schema_table_lock_waits Views .........................................................................

These views display which sessions are blocked waiting on metadata locks, and what is blocking them.

The column descriptions here are brief. For additional information, see the description of the Performance Schema note 'metadata_locks': performance-schema-metadata-locks-table. table at note performance-schema-metadata-locks-table::.

The note 'schema_table_lock_waits': sys-schema-table-lock-waits. and note 'x$schema_table_lock_waits': sys-schema-table-lock-waits. views have these columns:

 File: manual.info.tmp, Node: sys-schema-table-statistics, Next: sys-schema-table-statistics-with-buffer, Prev: sys-schema-table-lock-waits, Up: sys-schema-views

26.4.3.29 The schema_table_statistics and x$schema_table_statistics Views .........................................................................

These views summarize table statistics. By default, rows are sorted by descending total wait time (tables with most contention first).

These views user a helper view, 'x$ps_schema_table_statistics_io'.

The note 'schema_table_statistics': sys-schema-table-statistics. and note 'x$schema_table_statistics': sys-schema-table-statistics. views have these columns:

 File: manual.info.tmp, Node: sys-schema-table-statistics-with-buffer, Next: sys-schema-tables-with-full-table-scans, Prev: sys-schema-table-statistics, Up: sys-schema-views

26.4.3.30 The schema_table_statistics_with_buffer and x$schema_table_statistics_with_buffer Views .................................................................................................

These views summarize table statistics, including 'InnoDB' buffer pool statistics. By default, rows are sorted by descending total wait time (tables with most contention first).

These views user a helper view, 'x$ps_schema_table_statistics_io'.

The note 'schema_table_statistics_with_buffer': sys-schema-table-statistics-with-buffer. and note 'x$schema_table_statistics_with_buffer': sys-schema-table-statistics-with-buffer. views have these columns:

 File: manual.info.tmp, Node: sys-schema-tables-with-full-table-scans, Next: sys-schema-unused-indexes, Prev: sys-schema-table-statistics-with-buffer, Up: sys-schema-views

26.4.3.31 The schema_tables_with_full_table_scans and x$schema_tables_with_full_table_scans Views .................................................................................................

These views display which tables are being accessed with full table scans. By default, rows are sorted by descending rows scanned.

The note 'schema_tables_with_full_table_scans': sys-schema-tables-with-full-table-scans. and note 'x$schema_tables_with_full_table_scans': sys-schema-tables-with-full-table-scans. views have these columns:

 File: manual.info.tmp, Node: sys-schema-unused-indexes, Next: sys-session, Prev: sys-schema-tables-with-full-table-scans, Up: sys-schema-views

26.4.3.32 The schema_unused_indexes View ........................................

These views display indexes for which there are no events, which indicates that they are not being used. By default, rows are sorted by schema and table.

This view is most useful when the server has been up and processing long enough that its workload is representative. Otherwise, presence of an index in this view may not be meaningful.

The *note 'schema_unused_indexes': sys-schema-unused-indexes. view has these columns:

 File: manual.info.tmp, Node: sys-session, Next: sys-session-ssl-status, Prev: sys-schema-unused-indexes, Up: sys-schema-views

26.4.3.33 The session and x$session Views .........................................

These views are similar to note 'processlist': sys-processlist. and note 'x$processlist': sys-processlist, but they filter out background processes to display only user sessions. For descriptions of the columns, see *note sys-processlist::.

 File: manual.info.tmp, Node: sys-session-ssl-status, Next: sys-statement-analysis, Prev: sys-session, Up: sys-schema-views

26.4.3.34 The session_ssl_status View .....................................

For each connection, this view displays the SSL version, cipher, and count of reused SSL sessions.

The *note 'session_ssl_status': sys-session-ssl-status. view has these columns:

 File: manual.info.tmp, Node: sys-statement-analysis, Next: sys-statements-with-errors-or-warnings, Prev: sys-session-ssl-status, Up: sys-schema-views

26.4.3.35 The statement_analysis and x$statement_analysis Views ...............................................................

These views list normalized statements with aggregated statistics. The content mimics the MySQL Enterprise Monitor Query Analysis view. By default, rows are sorted by descending total latency.

The note 'statement_analysis': sys-statement-analysis. and note 'x$statement_analysis': sys-statement-analysis. views have these columns:

 File: manual.info.tmp, Node: sys-statements-with-errors-or-warnings, Next: sys-statements-with-full-table-scans, Prev: sys-statement-analysis, Up: sys-schema-views

26.4.3.36 The statements_with_errors_or_warnings and x$statements_with_errors_or_warnings Views ...............................................................................................

These views display normalized statements that have produced errors or warnings. By default, rows are sorted by descending error and warning counts.

The note 'statements_with_errors_or_warnings': sys-statements-with-errors-or-warnings. and note 'x$statements_with_errors_or_warnings': sys-statements-with-errors-or-warnings. views have these columns:

 File: manual.info.tmp, Node: sys-statements-with-full-table-scans, Next: sys-statements-with-runtimes-in-95th-percentile, Prev: sys-statements-with-errors-or-warnings, Up: sys-schema-views

26.4.3.37 The statements_with_full_table_scans and x$statements_with_full_table_scans Views ...........................................................................................

These views display normalized statements that have done full table scans. By default, rows are sorted by descending percentage of time a full scan was done and descending total latency.

The note 'statements_with_full_table_scans': sys-statements-with-full-table-scans. and note 'x$statements_with_full_table_scans': sys-statements-with-full-table-scans. views have these columns:

 File: manual.info.tmp, Node: sys-statements-with-runtimes-in-95th-percentile, Next: sys-statements-with-sorting, Prev: sys-statements-with-full-table-scans, Up: sys-schema-views

26.4.3.38 The statements_with_runtimes_in_95th_percentile and x$statements_with_runtimes_in_95th_percentile Views .................................................................................................................

These views list statements with runtimes in the 95th percentile. By default, rows are sorted by descending average latency.

Both views use two helper views, 'xpsdigestavglatencydistributionandxps_digest_95th_percentile_by_avg_us'.

The note 'statements_with_runtimes_in_95th_percentile': sys-statements-with-runtimes-in-95th-percentile. and note 'x$statements_with_runtimes_in_95th_percentile': sys-statements-with-runtimes-in-95th-percentile. views have these columns:

 File: manual.info.tmp, Node: sys-statements-with-sorting, Next: sys-statements-with-temp-tables, Prev: sys-statements-with-runtimes-in-95th-percentile, Up: sys-schema-views

26.4.3.39 The statements_with_sorting and x$statements_with_sorting Views .........................................................................

These views list normalized statements that have performed sorts. By default, rows are sorted by descending total latency.

The note 'statements_with_sorting': sys-statements-with-sorting. and note 'x$statements_with_sorting': sys-statements-with-sorting. views have these columns:

 File: manual.info.tmp, Node: sys-statements-with-temp-tables, Next: sys-user-summary, Prev: sys-statements-with-sorting, Up: sys-schema-views

26.4.3.40 The statements_with_temp_tables and x$statements_with_temp_tables Views .................................................................................

These views list normalized statements that have used temporary tables. By default, rows are sorted by descending number of on-disk temporary tables used and descending number of in-memory temporary tables used.

The note 'statements_with_temp_tables': sys-statements-with-temp-tables. and note 'x$statements_with_temp_tables': sys-statements-with-temp-tables. views have these columns:

 File: manual.info.tmp, Node: sys-user-summary, Next: sys-user-summary-by-file-io, Prev: sys-statements-with-temp-tables, Up: sys-schema-views

26.4.3.41 The user_summary and x$user_summary Views ...................................................

These views summarize statement activity, file I/O, and connections, grouped by user. By default, rows are sorted by descending total latency.

The note 'user_summary': sys-user-summary. and note 'x$user_summary': sys-user-summary. views have these columns:

 File: manual.info.tmp, Node: sys-user-summary-by-file-io, Next: sys-user-summary-by-file-io-type, Prev: sys-user-summary, Up: sys-schema-views

26.4.3.42 The user_summary_by_file_io and x$user_summary_by_file_io Views .........................................................................

These views summarize file I/O, grouped by user. By default, rows are sorted by descending total file I/O latency.

The note 'user_summary_by_file_io': sys-user-summary-by-file-io. and note 'x$user_summary_by_file_io': sys-user-summary-by-file-io. views have these columns:

 File: manual.info.tmp, Node: sys-user-summary-by-file-io-type, Next: sys-user-summary-by-stages, Prev: sys-user-summary-by-file-io, Up: sys-schema-views

26.4.3.43 The user_summary_by_file_io_type and x$user_summary_by_file_io_type Views ...................................................................................

These views summarize file I/O, grouped by user and event type. By default, rows are sorted by user and descending total latency.

The note 'user_summary_by_file_io_type': sys-user-summary-by-file-io-type. and note 'x$user_summary_by_file_io_type': sys-user-summary-by-file-io-type. views have these columns:

 File: manual.info.tmp, Node: sys-user-summary-by-stages, Next: sys-user-summary-by-statement-latency, Prev: sys-user-summary-by-file-io-type, Up: sys-schema-views

26.4.3.44 The user_summary_by_stages and x$user_summary_by_stages Views .......................................................................

These views summarize stages, grouped by user. By default, rows are sorted by user and descending total stage latency.

The note 'user_summary_by_stages': sys-user-summary-by-stages. and note 'x$user_summary_by_stages': sys-user-summary-by-stages. views have these columns:

 File: manual.info.tmp, Node: sys-user-summary-by-statement-latency, Next: sys-user-summary-by-statement-type, Prev: sys-user-summary-by-stages, Up: sys-schema-views

26.4.3.45 The user_summary_by_statement_latency and x$user_summary_by_statement_latency Views .............................................................................................

These views summarize overall statement statistics, grouped by user. By default, rows are sorted by descending total latency.

The note 'user_summary_by_statement_latency': sys-user-summary-by-statement-latency. and note 'x$user_summary_by_statement_latency': sys-user-summary-by-statement-latency. views have these columns:

 File: manual.info.tmp, Node: sys-user-summary-by-statement-type, Next: sys-version, Prev: sys-user-summary-by-statement-latency, Up: sys-schema-views

26.4.3.46 The user_summary_by_statement_type and x$user_summary_by_statement_type Views .......................................................................................

These views summarize informaion about statements executed, grouped by user and statement type. By default, rows are sorted by user and descending total latency.

The note 'user_summary_by_statement_type': sys-user-summary-by-statement-type. and note 'x$user_summary_by_statement_type': sys-user-summary-by-statement-type. views have these columns:

 File: manual.info.tmp, Node: sys-version, Next: sys-wait-classes-global-by-avg-latency, Prev: sys-user-summary-by-statement-type, Up: sys-schema-views

26.4.3.47 The version View ..........................

This view provides the current *note 'sys': sys-schema. schema and MySQL server versions.

Note:

As of MySQL 5.7.28, this view is deprecated and subject to removal in a future MySQL version. Applications that use it should be migrated to use an alternative instead. For example, use the 'VERSION()' function to retrieve the MySQL server version.

The *note 'version': sys-version. view has these columns:

 File: manual.info.tmp, Node: sys-wait-classes-global-by-avg-latency, Next: sys-wait-classes-global-by-latency, Prev: sys-version, Up: sys-schema-views

26.4.3.48 The wait_classes_global_by_avg_latency and x$wait_classes_global_by_avg_latency Views ...............................................................................................

These views summarize wait class average latencies, grouped by event class. By default, rows are sorted by descending average latency. Idle events are ignored.

An event class is determined by stripping from the event name everything after the first three components. For example, the class for 'wait/io/file/sql/slow_log' is 'wait/io/file'.

The note 'wait_classes_global_by_avg_latency': sys-wait-classes-global-by-avg-latency. and note 'x$wait_classes_global_by_avg_latency': sys-wait-classes-global-by-avg-latency. views have these columns:

 File: manual.info.tmp, Node: sys-wait-classes-global-by-latency, Next: sys-waits-by-host-by-latency, Prev: sys-wait-classes-global-by-avg-latency, Up: sys-schema-views

26.4.3.49 The wait_classes_global_by_latency and x$wait_classes_global_by_latency Views .......................................................................................

These views summarize wait class total latencies, grouped by event class. By default, rows are sorted by descending total latency. Idle events are ignored.

An event class is determined by stripping from the event name everything after the first three components. For example, the class for 'wait/io/file/sql/slow_log' is 'wait/io/file'.

The note 'wait_classes_global_by_latency': sys-wait-classes-global-by-latency. and note 'x$wait_classes_global_by_latency': sys-wait-classes-global-by-latency. views have these columns:

 File: manual.info.tmp, Node: sys-waits-by-host-by-latency, Next: sys-waits-by-user-by-latency, Prev: sys-wait-classes-global-by-latency, Up: sys-schema-views

26.4.3.50 The waits_by_host_by_latency and x$waits_by_host_by_latency Views ...........................................................................

These views summarize wait events, grouped by host and event. By default, rows are sorted by host and descending total latency. Idle events are ignored.

The note 'waits_by_host_by_latency': sys-waits-by-host-by-latency. and note 'x$waits_by_host_by_latency': sys-waits-by-host-by-latency. views have these columns:

 File: manual.info.tmp, Node: sys-waits-by-user-by-latency, Next: sys-waits-global-by-latency, Prev: sys-waits-by-host-by-latency, Up: sys-schema-views

26.4.3.51 The waits_by_user_by_latency and x$waits_by_user_by_latency Views ...........................................................................

These views summarize wait events, grouped by user and event. By default, rows are sorted by user and descending total latency. Idle events are ignored.

The note 'waits_by_user_by_latency': sys-waits-by-user-by-latency. and note 'x$waits_by_user_by_latency': sys-waits-by-user-by-latency. views have these columns:

 File: manual.info.tmp, Node: sys-waits-global-by-latency, Prev: sys-waits-by-user-by-latency, Up: sys-schema-views

26.4.3.52 The waits_global_by_latency and x$waits_global_by_latency Views .........................................................................

These views summarize wait events, grouped by event. By default, rows are sorted by descending total latency. Idle events are ignored.

The note 'waits_global_by_latency': sys-waits-global-by-latency. and note 'x$waits_global_by_latency': sys-waits-global-by-latency. views have these columns:

 File: manual.info.tmp, Node: sys-schema-procedures, Next: sys-schema-functions, Prev: sys-schema-views, Up: sys-schema-reference

26.4.4 sys Schema Stored Procedures

The following sections describe *note 'sys': sys-schema. schema stored procedures.

 File: manual.info.tmp, Node: sys-create-synonym-db, Next: sys-diagnostics, Prev: sys-schema-procedures, Up: sys-schema-procedures

26.4.4.1 The create_synonym_db() Procedure ..........................................

Given a schema name, this procedure creates a synonym schema containing views that refer to all the tables and views in the original schema. This can be used, for example, to create a shorter name by which to refer to a schema with a long name (such as 'info' rather than 'INFORMATION_SCHEMA').

Parameters

Example

 mysql> SHOW DATABASES;
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | mysql              |
 | performance_schema |
 | sys                |
 | world              |
 +--------------------+
 mysql> CALL sys.create_synonym_db('INFORMATION_SCHEMA', 'info');
 +---------------------------------------+
 | summary                               |
 +---------------------------------------+
 | Created 63 views in the info database |
 +---------------------------------------+
 mysql> SHOW DATABASES;
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | info               |
 | mysql              |
 | performance_schema |
 | sys                |
 | world              |
 +--------------------+
 mysql> SHOW FULL TABLES FROM info;
 +---------------------------------------+------------+
 | Tables_in_info                        | Table_type |
 +---------------------------------------+------------+
 | character_sets                        | VIEW       |
 | collation_character_set_applicability | VIEW       |
 | collations                            | VIEW       |
 | column_privileges                     | VIEW       |
 | columns                               | VIEW       |
 ...

 File: manual.info.tmp, Node: sys-diagnostics, Next: sys-execute-prepared-stmt, Prev: sys-create-synonym-db, Up: sys-schema-procedures

26.4.4.2 The diagnostics() Procedure ....................................

Creates a report of the current server status for diagnostic purposes.

This procedure disables binary logging during its execution by manipulating the session value of the 'sql_log_bin' system variable. That is a restricted operation, so the procedure requires privileges sufficient to set restricted session variables. See *note system-variable-privileges::.

Data collected for *note 'diagnostics()': sys-diagnostics. includes this information:

Some of the sys schema views are calculated as initial (optional), overall, and delta values:

Parameters

Configuration Options

note 'diagnostics()': sys-diagnostics. operation can be modified using the following configuration options or their corresponding user-defined variables (see note sys-sys-config::):

Example

Create a diagnostics report that starts an iteration every 30 seconds and runs for at most 120 seconds using the current Performance Schema settings:

 mysql> CALL sys.diagnostics(120, 30, 'current');

To capture the output from the 'diagnostics()' procedure in a file as it runs, use the note 'mysql': mysql. client 'tee filename' and 'notee' commands (see note mysql-commands::):

 mysql> tee diag.out;
 mysql> CALL sys.diagnostics(120, 30, 'current');
 mysql> notee;

 File: manual.info.tmp, Node: sys-execute-prepared-stmt, Next: sys-ps-setup-disable-background-threads, Prev: sys-diagnostics, Up: sys-schema-procedures

26.4.4.3 The execute_prepared_stmt() Procedure ..............................................

Given an SQL statement as a string, executes it as a prepared statement. The prepared statement is deallocated after execution, so it is not subject to reuse. Thus, this procedure is useful primarily for executing dynamic statements on a one-time basis.

This procedure uses 'sys_execute_prepared_stmt' as the prepared statement name. If that statement name exists when the procedure is called, its previous content is destroyed.

Parameters

Configuration Options

note 'execute_prepared_stmt()': sys-execute-prepared-stmt. operation can be modified using the following configuration options or their corresponding user-defined variables (see note sys-sys-config::):

Example

 mysql> CALL sys.execute_prepared_stmt('SELECT COUNT(*) FROM mysql.user');
 +----------+
 | COUNT(*) |
 +----------+
 |       15 |
 +----------+

 File: manual.info.tmp, Node: sys-ps-setup-disable-background-threads, Next: sys-ps-setup-disable-consumer, Prev: sys-execute-prepared-stmt, Up: sys-schema-procedures

26.4.4.4 The ps_setup_disable_background_threads() Procedure ............................................................

Disables Performance Schema instrumentation for all background threads. Produces a result set indicating how many background threads were disabled. Already disabled threads do not count.

Parameters

None.

Example

 mysql> CALL sys.ps_setup_disable_background_threads();
 +--------------------------------+
 | summary                        |
 +--------------------------------+
 | Disabled 24 background threads |
 +--------------------------------+

 File: manual.info.tmp, Node: sys-ps-setup-disable-consumer, Next: sys-ps-setup-disable-instrument, Prev: sys-ps-setup-disable-background-threads, Up: sys-schema-procedures

26.4.4.5 The ps_setup_disable_consumer() Procedure ..................................................

Disables Performance Schema consumers with names that contain the argument. Produces a result set indicating how many consumers were disabled. Already disabled consumers do not count.

Parameters

Example

Disable all statement consumers:

 mysql> CALL sys.ps_setup_disable_consumer('statement');
 +----------------------+
 | summary              |
 +----------------------+
 | Disabled 4 consumers |
 +----------------------+

 File: manual.info.tmp, Node: sys-ps-setup-disable-instrument, Next: sys-ps-setup-disable-thread, Prev: sys-ps-setup-disable-consumer, Up: sys-schema-procedures

26.4.4.6 The ps_setup_disable_instrument() Procedure ....................................................

Disables Performance Schema instruments with names that contain the argument. Produces a result set indicating how many instruments were disabled. Already disabled instruments do not count.

Parameters

Example

Disable a specific instrument:

 mysql> CALL sys.ps_setup_disable_instrument('wait/lock/metadata/sql/mdl');
 +-----------------------+
 | summary               |
 +-----------------------+
 | Disabled 1 instrument |
 +-----------------------+

Disable all mutex instruments:

 mysql> CALL sys.ps_setup_disable_instrument('mutex');
 +--------------------------+
 | summary                  |
 +--------------------------+
 | Disabled 177 instruments |
 +--------------------------+

 File: manual.info.tmp, Node: sys-ps-setup-disable-thread, Next: sys-ps-setup-enable-background-threads, Prev: sys-ps-setup-disable-instrument, Up: sys-schema-procedures

26.4.4.7 The ps_setup_disable_thread() Procedure ................................................

Given a connection ID, disables Performance Schema instrumentation for the thread. Produces a result set indicating how many threads were disabled. Already disabled threads do not count.

Parameters

Example

Disable a specific connection by its connection ID:

 mysql> CALL sys.ps_setup_disable_thread(225);
 +-------------------+
 | summary           |
 +-------------------+
 | Disabled 1 thread |
 +-------------------+

Disable the current connection:

 mysql> CALL sys.ps_setup_disable_thread(CONNECTION_ID());
 +-------------------+
 | summary           |
 +-------------------+
 | Disabled 1 thread |
 +-------------------+

 File: manual.info.tmp, Node: sys-ps-setup-enable-background-threads, Next: sys-ps-setup-enable-consumer, Prev: sys-ps-setup-disable-thread, Up: sys-schema-procedures

26.4.4.8 The ps_setup_enable_background_threads() Procedure ...........................................................

Enables Performance Schema instrumentation for all background threads. Produces a result set indicating how many background threads were enabled. Already enabled threads do not count.

Parameters

None.

Example

 mysql> CALL sys.ps_setup_enable_background_threads();
 +-------------------------------+
 | summary                       |
 +-------------------------------+
 | Enabled 24 background threads |
 +-------------------------------+

 File: manual.info.tmp, Node: sys-ps-setup-enable-consumer, Next: sys-ps-setup-enable-instrument, Prev: sys-ps-setup-enable-background-threads, Up: sys-schema-procedures

26.4.4.9 The ps_setup_enable_consumer() Procedure .................................................

Enables Performance Schema consumers with names that contain the argument. Produces a result set indicating how many consumers were enabled. Already enabled consumers do not count.

Parameters

Example

Enable all statement consumers:

 mysql> CALL sys.ps_setup_enable_consumer('statement');
 +---------------------+
 | summary             |
 +---------------------+
 | Enabled 4 consumers |
 +---------------------+

 File: manual.info.tmp, Node: sys-ps-setup-enable-instrument, Next: sys-ps-setup-enable-thread, Prev: sys-ps-setup-enable-consumer, Up: sys-schema-procedures

26.4.4.10 The ps_setup_enable_instrument() Procedure ....................................................

Enables Performance Schema instruments with names that contain the argument. Produces a result set indicating how many instruments were enabled. Already enabled instruments do not count.

Parameters

Example

Enable a specific instrument:

 mysql> CALL sys.ps_setup_enable_instrument('wait/lock/metadata/sql/mdl');
 +----------------------+
 | summary              |
 +----------------------+
 | Enabled 1 instrument |
 +----------------------+

Enable all mutex instruments:

 mysql> CALL sys.ps_setup_enable_instrument('mutex');
 +-------------------------+
 | summary                 |
 +-------------------------+
 | Enabled 177 instruments |
 +-------------------------+

 File: manual.info.tmp, Node: sys-ps-setup-enable-thread, Next: sys-ps-setup-reload-saved, Prev: sys-ps-setup-enable-instrument, Up: sys-schema-procedures

26.4.4.11 The ps_setup_enable_thread() Procedure ................................................

Given a connection ID, enables Performance Schema instrumentation for the thread. Produces a result set indicating how many threads were enabled. Already enabled threads do not count.

Parameters

Example

Enable a specific connection by its connection ID:

 mysql> CALL sys.ps_setup_enable_thread(225);
 +------------------+
 | summary          |
 +------------------+
 | Enabled 1 thread |
 +------------------+

Enable the current connection:

 mysql> CALL sys.ps_setup_enable_thread(CONNECTION_ID());
 +------------------+
 | summary          |
 +------------------+
 | Enabled 1 thread |
 +------------------+

 File: manual.info.tmp, Node: sys-ps-setup-reload-saved, Next: sys-ps-setup-reset-to-default, Prev: sys-ps-setup-enable-thread, Up: sys-schema-procedures

26.4.4.12 The ps_setup_reload_saved() Procedure ...............................................

Reloads a Performance Schema configuration saved earlier within the same session using note 'ps_setup_save()': sys-ps-setup-save. For more information, see the description of note 'ps_setup_save()': sys-ps-setup-save.

This procedure disables binary logging during its execution by manipulating the session value of the 'sql_log_bin' system variable. That is a restricted operation, so the procedure requires privileges sufficient to set restricted session variables. See *note system-variable-privileges::.

Parameters

None.

 File: manual.info.tmp, Node: sys-ps-setup-reset-to-default, Next: sys-ps-setup-save, Prev: sys-ps-setup-reload-saved, Up: sys-schema-procedures

26.4.4.13 The ps_setup_reset_to_default() Procedure ...................................................

Resets the Performance Schema configuration to its default settings.

Parameters

Example

 mysql> CALL sys.ps_setup_reset_to_default(TRUE)\G
 *************************** 1. row ***************************
 status: Resetting: setup_actors
 DELETE
 FROM performance_schema.setup_actors
 WHERE NOT (HOST = '%' AND USER = '%' AND ROLE = '%')

 *************************** 1. row ***************************
 status: Resetting: setup_actors
 INSERT IGNORE INTO performance_schema.setup_actors
 VALUES ('%', '%', '%')

 ...

 File: manual.info.tmp, Node: sys-ps-setup-save, Next: sys-ps-setup-show-disabled, Prev: sys-ps-setup-reset-to-default, Up: sys-schema-procedures

26.4.4.14 The ps_setup_save() Procedure .......................................

Saves the current Performance Schema configuration. This enables you to alter the configuration temporarily for debugging or other purposes, then restore it to the previous state by invoking the *note 'ps_setup_reload_saved()': sys-ps-setup-reload-saved. procedure.

To prevent other simultaneous calls to save the configuration, note 'ps_setup_save()': sys-ps-setup-save. acquires an advisory lock named 'sys.ps_setup_save' by calling the 'GET_LOCK()' function. note 'ps_setup_save()': sys-ps-setup-save. takes a timeout parameter to indicate how many seconds to wait if the lock already exists (which indicates that some other session has a saved configuration outstanding). If the timeout expires without obtaining the lock, *note 'ps_setup_save()': sys-ps-setup-save. fails.

It is intended you call note 'ps_setup_reload_saved()': sys-ps-setup-reload-saved. later within the same session as note 'ps_setup_save()': sys-ps-setup-save. because the configuration is saved in 'TEMPORARY' tables. note 'ps_setup_save()': sys-ps-setup-save. drops the temporary tables and releases the lock. If you end your session without invoking note 'ps_setup_save()': sys-ps-setup-save, the tables and lock disappear automatically.

This procedure disables binary logging during its execution by manipulating the session value of the 'sql_log_bin' system variable. That is a restricted operation, so the procedure requires privileges sufficient to set restricted session variables. See *note system-variable-privileges::.

Parameters

Example

 mysql> CALL sys.ps_setup_save(10);

 ... MAKE PERFORMANCE SCHEMA CONFIGURATION CHANGES ...

 mysql> CALL sys.ps_setup_reload_saved();

 File: manual.info.tmp, Node: sys-ps-setup-show-disabled, Next: sys-ps-setup-show-disabled-consumers, Prev: sys-ps-setup-save, Up: sys-schema-procedures

26.4.4.15 The ps_setup_show_disabled() Procedure ................................................

Displays all currently disabled Performance Schema configuration.

Parameters

Example

 mysql> CALL sys.ps_setup_show_disabled(TRUE, TRUE);
 +----------------------------+
 | performance_schema_enabled |
 +----------------------------+
 |                          1 |
 +----------------------------+

 +---------------+
 | enabled_users |
 +---------------+
 | '%'@'%'       |
 +---------------+

 +-------------+----------------------+---------+-------+
 | object_type | objects              | enabled | timed |
 +-------------+----------------------+---------+-------+
 | EVENT       | mysql.%              | NO      | NO    |
 | EVENT       | performance_schema.% | NO      | NO    |
 | EVENT       | information_schema.% | NO      | NO    |
 | FUNCTION    | mysql.%              | NO      | NO    |
 | FUNCTION    | performance_schema.% | NO      | NO    |
 | FUNCTION    | information_schema.% | NO      | NO    |
 | PROCEDURE   | mysql.%              | NO      | NO    |
 | PROCEDURE   | performance_schema.% | NO      | NO    |
 | PROCEDURE   | information_schema.% | NO      | NO    |
 | TABLE       | mysql.%              | NO      | NO    |
 | TABLE       | performance_schema.% | NO      | NO    |
 | TABLE       | information_schema.% | NO      | NO    |
 | TRIGGER     | mysql.%              | NO      | NO    |
 | TRIGGER     | performance_schema.% | NO      | NO    |
 | TRIGGER     | information_schema.% | NO      | NO    |
 +-------------+----------------------+---------+-------+

 ...

 File: manual.info.tmp, Node: sys-ps-setup-show-disabled-consumers, Next: sys-ps-setup-show-disabled-instruments, Prev: sys-ps-setup-show-disabled, Up: sys-schema-procedures

26.4.4.16 The ps_setup_show_disabled_consumers() Procedure ..........................................................

Displays all currently disabled Performance Schema consumers.

Parameters

None.

Example

 mysql> CALL sys.ps_setup_show_disabled_consumers();
 +----------------------------------+
 | disabled_consumers               |
 +----------------------------------+
 | events_stages_current            |
 | events_stages_history            |
 | events_stages_history_long       |
 | events_statements_history        |
 | events_statements_history_long   |
 | events_transactions_history      |
 | events_transactions_history_long |
 | events_waits_current             |
 | events_waits_history             |
 | events_waits_history_long        |
 +----------------------------------+

 File: manual.info.tmp, Node: sys-ps-setup-show-disabled-instruments, Next: sys-ps-setup-show-enabled, Prev: sys-ps-setup-show-disabled-consumers, Up: sys-schema-procedures

26.4.4.17 The ps_setup_show_disabled_instruments() Procedure ............................................................

Displays all currently disabled Performance Schema instruments. This might be a long list.

Parameters

None.

Example

 mysql> CALL sys.ps_setup_show_disabled_instruments()\G
 *************************** 1. row ***************************
 disabled_instruments: wait/synch/mutex/sql/TC_LOG_MMAP::LOCK_tc
                timed: NO
 *************************** 2. row ***************************
 disabled_instruments: wait/synch/mutex/sql/THD::LOCK_query_plan
                timed: NO
 *************************** 3. row ***************************
 disabled_instruments: wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_commit
                timed: NO
 ...

 File: manual.info.tmp, Node: sys-ps-setup-show-enabled, Next: sys-ps-setup-show-enabled-consumers, Prev: sys-ps-setup-show-disabled-instruments, Up: sys-schema-procedures

26.4.4.18 The ps_setup_show_enabled() Procedure ...............................................

Displays all currently enabled Performance Schema configuration.

Parameters

Example

 mysql> CALL sys.ps_setup_show_enabled(FALSE, FALSE);
 +----------------------------+
 | performance_schema_enabled |
 +----------------------------+
 |                          1 |
 +----------------------------+
 1 row in set (0.00 sec)

 +---------------+
 | enabled_users |
 +---------------+
 | '%'@'%'       |
 +---------------+
 1 row in set (0.00 sec)

 +-------------+---------+---------+-------+
 | object_type | objects | enabled | timed |
 +-------------+---------+---------+-------+
 | EVENT       | %.%     | YES     | YES   |
 | FUNCTION    | %.%     | YES     | YES   |
 | PROCEDURE   | %.%     | YES     | YES   |
 | TABLE       | %.%     | YES     | YES   |
 | TRIGGER     | %.%     | YES     | YES   |
 +-------------+---------+---------+-------+
 5 rows in set (0.00 sec)

 +---------------------------+
 | enabled_consumers         |
 +---------------------------+
 | events_statements_current |
 | events_statements_history |
 | global_instrumentation    |
 | statements_digest         |
 | thread_instrumentation    |
 +---------------------------+

 File: manual.info.tmp, Node: sys-ps-setup-show-enabled-consumers, Next: sys-ps-setup-show-enabled-instruments, Prev: sys-ps-setup-show-enabled, Up: sys-schema-procedures

26.4.4.19 The ps_setup_show_enabled_consumers() Procedure .........................................................

Displays all currently enabled Performance Schema consumers.

Parameters

None.

Example

 mysql> CALL sys.ps_setup_show_enabled_consumers();
 +---------------------------+
 | enabled_consumers         |
 +---------------------------+
 | events_statements_current |
 | events_statements_history |
 | global_instrumentation    |
 | statements_digest         |
 | thread_instrumentation    |
 +---------------------------+

 File: manual.info.tmp, Node: sys-ps-setup-show-enabled-instruments, Next: sys-ps-statement-avg-latency-histogram, Prev: sys-ps-setup-show-enabled-consumers, Up: sys-schema-procedures

26.4.4.20 The ps_setup_show_enabled_instruments() Procedure ...........................................................

Displays all currently enabled Performance Schema instruments. This might be a long list.

Parameters

None.

Example

 mysql> CALL sys.ps_setup_show_enabled_instruments()\G
 *************************** 1. row ***************************
 enabled_instruments: wait/io/file/sql/map
               timed: YES
 *************************** 2. row ***************************
 enabled_instruments: wait/io/file/sql/binlog
               timed: YES
 *************************** 3. row ***************************
 enabled_instruments: wait/io/file/sql/binlog_cache
               timed: YES
 ...

 File: manual.info.tmp, Node: sys-ps-statement-avg-latency-histogram, Next: sys-ps-trace-statement-digest, Prev: sys-ps-setup-show-enabled-instruments, Up: sys-schema-procedures

26.4.4.21 The ps_statement_avg_latency_histogram() Procedure ............................................................

Displays a textual histogram graph of the average latency values across all normalized statements tracked within the Performance Schema *note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables. table.

This procedure can be used to display a very high-level picture of the latency distribution of statements running within this MySQL instance.

Parameters

None.

Example

The histogram output in statement units. For example, '* = 2 units' in the histogram legend means that each '*' character represents 2 statements.

 mysql> CALL sys.ps_statement_avg_latency_histogram()\G
 *************************** 1. row ***************************
 Performance Schema Statement Digest Average Latency Histogram:

   . = 1 unit
   * = 2 units
   # = 3 units

 (0 - 66ms)     88  | #############################
 (66 - 133ms)   14  | ..............
 (133 - 199ms)  4   | ....
 (199 - 265ms)  5   | **
 (265 - 332ms)  1   | .
 (332 - 398ms)  0   |
 (398 - 464ms)  1   | .
 (464 - 531ms)  0   |
 (531 - 597ms)  0   |
 (597 - 663ms)  0   |
 (663 - 730ms)  0   |
 (730 - 796ms)  0   |
 (796 - 863ms)  0   |
 (863 - 929ms)  0   |
 (929 - 995ms)  0   |
 (995 - 1062ms) 0   |

   Total Statements: 114; Buckets: 16; Bucket Size: 66 ms;

 File: manual.info.tmp, Node: sys-ps-trace-statement-digest, Next: sys-ps-trace-thread, Prev: sys-ps-statement-avg-latency-histogram, Up: sys-schema-procedures

26.4.4.22 The ps_trace_statement_digest() Procedure ...................................................

Traces all Performance Schema instrumentation for a specific statement digest.

If you find a statement of interest within the Performance Schema *note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables. table, specify its 'DIGEST' column MD5 value to this procedure and indicate the polling duration and interval. The result is a report of all statistics tracked within Performance Schema for that digest for the interval.

The procedure also attempts to execute note 'EXPLAIN': explain. for the longest running example of the digest during the interval. This attempt might fail because the Performance Schema truncates long 'SQL_TEXT' values. Consequently, note 'EXPLAIN': explain. fails due to parse errors.

This procedure disables binary logging during its execution by manipulating the session value of the 'sql_log_bin' system variable. That is a restricted operation, so the procedure requires privileges sufficient to set restricted session variables. See *note system-variable-privileges::.

Parameters

Example

 mysql> CALL sys.ps_trace_statement_digest('891ec6860f98ba46d89dd20b0c03652c', 10, 0.1, TRUE, TRUE);
 +--------------------+
 | SUMMARY STATISTICS |
 +--------------------+
 | SUMMARY STATISTICS |
 +--------------------+
 1 row in set (9.11 sec)

 +------------+-----------+-----------+-----------+---------------+------------+------------+
 | executions | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scans |
 +------------+-----------+-----------+-----------+---------------+------------+------------+
 |         21 | 4.11 ms   | 2.00 ms   |         0 |            21 |          0 |          0 |
 +------------+-----------+-----------+-----------+---------------+------------+------------+
 1 row in set (9.11 sec)

 +------------------------------------------+-------+-----------+
 | event_name                               | count | latency   |
 +------------------------------------------+-------+-----------+
 | stage/sql/checking query cache for query |    16 | 724.37 us |
 | stage/sql/statistics                     |    16 | 546.92 us |
 | stage/sql/freeing items                  |    18 | 520.11 us |
 | stage/sql/init                           |    51 | 466.80 us |
 ...
 | stage/sql/cleaning up                    |    18 | 11.92 us  |
 | stage/sql/executing                      |    16 | 6.95 us   |
 +------------------------------------------+-------+-----------+
 17 rows in set (9.12 sec)

 +---------------------------+
 | LONGEST RUNNING STATEMENT |
 +---------------------------+
 | LONGEST RUNNING STATEMENT |
 +---------------------------+
 1 row in set (9.16 sec)

 +-----------+-----------+-----------+-----------+---------------+------------+-----------+
 | thread_id | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scan |
 +-----------+-----------+-----------+-----------+---------------+------------+-----------+
 |    166646 | 618.43 us | 1.00 ms   |         0 |             1 |          0 |         0 |
 +-----------+-----------+-----------+-----------+---------------+------------+-----------+
 1 row in set (9.16 sec)

 # Truncated for clarity...
 +-----------------------------------------------------------------+
 | sql_text                                                        |
 +-----------------------------------------------------------------+
 | select hibeventhe0_.id as id1382_, hibeventhe0_.createdTime ... |
 +-----------------------------------------------------------------+
 1 row in set (9.17 sec)

 +------------------------------------------+-----------+
 | event_name                               | latency   |
 +------------------------------------------+-----------+
 | stage/sql/init                           | 8.61 us   |
 | stage/sql/Waiting for query cache lock   | 453.23 us |
 | stage/sql/init                           | 331.07 ns |
 | stage/sql/checking query cache for query | 43.04 us  |
 ...
 | stage/sql/freeing items                  | 30.46 us  |
 | stage/sql/cleaning up                    | 662.13 ns |
 +------------------------------------------+-----------+
 18 rows in set (9.23 sec)

 +----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
 | id | select_type | table        | type  | possible_keys | key       | key_len | ref         | rows | Extra |
 +----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
 |  1 | SIMPLE      | hibeventhe0_ | const | fixedTime     | fixedTime | 775     | const,const |    1 | NULL  |
 +----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
 1 row in set (9.27 sec)

 Query OK, 0 rows affected (9.28 sec)

 File: manual.info.tmp, Node: sys-ps-trace-thread, Next: sys-ps-truncate-all-tables, Prev: sys-ps-trace-statement-digest, Up: sys-schema-procedures

26.4.4.23 The ps_trace_thread() Procedure .........................................

Dumps all Performance Schema data for an instrumented thread to a '.dot' formatted graph file (for the DOT graph description language). Each result set returned from the procedure should be used for a complete graph.

This procedure disables binary logging during its execution by manipulating the session value of the 'sql_log_bin' system variable. That is a restricted operation, so the procedure requires privileges sufficient to set restricted session variables. See *note system-variable-privileges::.

Parameters

Example

 mysql> CALL sys.ps_trace_thread(25, CONCAT('/tmp/stack-', REPLACE(NOW(), ' ', '-'), '.dot'), NULL, NULL, TRUE, TRUE, TRUE);
 +-------------------+
 | summary           |
 +-------------------+
 | Disabled 1 thread |
 +-------------------+
 1 row in set (0.00 sec)

 +---------------------------------------------+
 | Info                                        |
 +---------------------------------------------+
 | Data collection starting for THREAD_ID = 25 |
 +---------------------------------------------+
 1 row in set (0.03 sec)

 +-----------------------------------------------------------+
 | Info                                                      |
 +-----------------------------------------------------------+
 | Stack trace written to /tmp/stack-2014-02-16-21:18:41.dot |
 +-----------------------------------------------------------+
 1 row in set (60.07 sec)

 +-------------------------------------------------------------------+
 | Convert to PDF                                                    |
 +-------------------------------------------------------------------+
 | dot -Tpdf -o /tmp/stack_25.pdf /tmp/stack-2014-02-16-21:18:41.dot |
 +-------------------------------------------------------------------+
 1 row in set (60.07 sec)

 +-------------------------------------------------------------------+
 | Convert to PNG                                                    |
 +-------------------------------------------------------------------+
 | dot -Tpng -o /tmp/stack_25.png /tmp/stack-2014-02-16-21:18:41.dot |
 +-------------------------------------------------------------------+
 1 row in set (60.07 sec)

 +------------------+
 | summary          |
 +------------------+
 | Enabled 1 thread |
 +------------------+
 1 row in set (60.32 sec)

 File: manual.info.tmp, Node: sys-ps-truncate-all-tables, Next: sys-statement-performance-analyzer, Prev: sys-ps-trace-thread, Up: sys-schema-procedures

26.4.4.24 The ps_truncate_all_tables() Procedure ................................................

Truncates all Performance Schema summary tables, resetting all aggregated instrumentation as a snapshot. Produces a result set indicating how many tables were truncated.

Parameters

Example

 mysql> CALL sys.ps_truncate_all_tables(FALSE);
 +---------------------+
 | summary             |
 +---------------------+
 | Truncated 44 tables |
 +---------------------+

 File: manual.info.tmp, Node: sys-statement-performance-analyzer, Next: sys-table-exists, Prev: sys-ps-truncate-all-tables, Up: sys-schema-procedures

26.4.4.25 The statement_performance_analyzer() Procedure ........................................................

Creates a report of the statements running on the server. The views are calculated based on the overall and/or delta activity.

This procedure disables binary logging during its execution by manipulating the session value of the 'sql_log_bin' system variable. That is a restricted operation, so the procedure requires privileges sufficient to set restricted session variables. See *note system-variable-privileges::.

Parameters

Configuration Options

note 'statement_performance_analyzer()': sys-statement-performance-analyzer. operation can be modified using the following configuration options or their corresponding user-defined variables (see note sys-sys-config::):

Example

To create a report with the queries in the 95th percentile since the last truncation of *note 'events_statements_summary_by_digest': performance-schema-statement-summary-tables. and with a one-minute delta period:

  1. Create a temporary table to store the initial snapshot.

  2. Create the initial snapshot.

  3. Save the initial snapshot in the temporary table.

  4. Wait one minute.

  5. Create a new snapshot.

  6. Perform analysis based on the new snapshot.

  7. Perform analysis based on the delta between the initial and new snapshots.

    mysql> CALL sys.statement_performance_analyzer('create_tmp', 'mydb.tmp_digests_ini', NULL); Query OK, 0 rows affected (0.08 sec)

    mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); Query OK, 0 rows affected (0.02 sec)

    mysql> CALL sys.statement_performance_analyzer('save', 'mydb.tmp_digests_ini', NULL); Query OK, 0 rows affected (0.00 sec)

    mysql> DO SLEEP(60); Query OK, 0 rows affected (1 min 0.00 sec)

    mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); Query OK, 0 rows affected (0.02 sec)

    mysql> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile'); +-----------------------------------------+ | Next Output | +-----------------------------------------+ | Queries with Runtime in 95th Percentile | +-----------------------------------------+ 1 row in set (0.05 sec)

    ...

    mysql> CALL sys.statement_performance_analyzer('delta', 'mydb.tmp_digests_ini', 'with_runtimes_in_95th_percentile'); +-----------------------------------------+ | Next Output | +-----------------------------------------+ | Queries with Runtime in 95th Percentile | +-----------------------------------------+ 1 row in set (0.03 sec)

    ...

Create an overall report of the 95th percentile queries and the top 10 queries with full table scans:

 mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);
 Query OK, 0 rows affected (0.01 sec)

 mysql> SET @sys.statement_performance_analyzer.limit = 10;
 Query OK, 0 rows affected (0.00 sec)

 mysql> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile,with_full_table_scans');
 +-----------------------------------------+
 | Next Output                             |
 +-----------------------------------------+
 | Queries with Runtime in 95th Percentile |
 +-----------------------------------------+
 1 row in set (0.01 sec)

 ...

 +-------------------------------------+
 | Next Output                         |
 +-------------------------------------+
 | Top 10 Queries with Full Table Scan |
 +-------------------------------------+
 1 row in set (0.09 sec)

 ...

Use a custom view showing the top 10 queries sorted by total execution time, refreshing the view every minute using the 'watch' command in Linux:

 mysql> CREATE OR REPLACE VIEW mydb.my_statements AS
        SELECT sys.format_statement(DIGEST_TEXT) AS query,
               SCHEMA_NAME AS db,
               COUNT_STAR AS exec_count,
               sys.format_time(SUM_TIMER_WAIT) AS total_latency,
               sys.format_time(AVG_TIMER_WAIT) AS avg_latency,
               ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg,
               ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg,
               ROUND(IFNULL(SUM_ROWS_AFFECTED / NULLIF(COUNT_STAR, 0), 0)) AS rows_affected_avg,
               DIGEST AS digest
          FROM performance_schema.events_statements_summary_by_digest
        ORDER BY SUM_TIMER_WAIT DESC;
 Query OK, 0 rows affected (0.10 sec)

 mysql> CALL sys.statement_performance_analyzer('create_table', 'mydb.digests_prev', NULL);
 Query OK, 0 rows affected (0.10 sec)

 $> watch -n 60 "mysql sys --table -e \"
 > SET @sys.statement_performance_analyzer.view = 'mydb.my_statements';
 > SET @sys.statement_performance_analyzer.limit = 10;
 > CALL statement_performance_analyzer('snapshot', NULL, NULL);
 > CALL statement_performance_analyzer('delta', 'mydb.digests_prev', 'custom');
 > CALL statement_performance_analyzer('save', 'mydb.digests_prev', NULL);
 > \""

 Every 60.0s: mysql sys --table -e "        ...  Mon Dec 22 10:58:51 2014

 +----------------------------------+
 | Next Output                      |
 +----------------------------------+
 | Top 10 Queries Using Custom View |
 +----------------------------------+
 +-------------------+-------+------------+---------------+-------------+---------------+-------------------+-------------------+----------------------------------+
 | query             | db    | exec_count | total_latency | avg_latency | rows_sent_avg | rows_examined_avg | rows_affected_avg | digest                           |
 +-------------------+-------+------------+---------------+-------------+---------------+-------------------+-------------------+----------------------------------+
 ...

 File: manual.info.tmp, Node: sys-table-exists, Prev: sys-statement-performance-analyzer, Up: sys-schema-procedures

26.4.4.26 The table_exists() Procedure ......................................

Tests whether a given table exists as a regular table, a 'TEMPORARY' table, or a view. The procedure returns the table type in an 'OUT' parameter. If both a temporary and a permanent table exist with the given name, 'TEMPORARY' is returned.

Parameters

Example

 mysql> CREATE DATABASE db1;
 Query OK, 1 row affected (0.01 sec)

 mysql> USE db1;
 Database changed

 mysql> CREATE TABLE t1 (id INT PRIMARY KEY);
 Query OK, 0 rows affected (0.03 sec)

 mysql> CREATE TABLE t2 (id INT PRIMARY KEY);
 Query OK, 0 rows affected (0.20 sec)

 mysql> CREATE view v_t1 AS SELECT * FROM t1;
 Query OK, 0 rows affected (0.02 sec)

 mysql> CREATE TEMPORARY TABLE t1 (id INT PRIMARY KEY);
 Query OK, 0 rows affected (0.00 sec)

 mysql> CALL sys.table_exists('db1', 't1', @exists); SELECT @exists;
 Query OK, 0 rows affected (0.01 sec)

 +-----------+
 | @exists   |
 +-----------+
 | TEMPORARY |
 +-----------+
 1 row in set (0.00 sec)

 mysql> CALL sys.table_exists('db1', 't2', @exists); SELECT @exists;
 Query OK, 0 rows affected (0.02 sec)

 +------------+
 | @exists    |
 +------------+
 | BASE TABLE |
 +------------+
 1 row in set (0.00 sec)

 mysql> CALL sys.table_exists('db1', 'v_t1', @exists); SELECT @exists;
 Query OK, 0 rows affected (0.02 sec)

 +---------+
 | @exists |
 +---------+
 | VIEW    |
 +---------+
 1 row in set (0.00 sec)

 mysql> CALL sys.table_exists('db1', 't3', @exists); SELECT @exists;
 Query OK, 0 rows affected (0.00 sec)

 +---------+
 | @exists |
 +---------+
 |         |
 +---------+
 1 row in set (0.00 sec)

 File: manual.info.tmp, Node: sys-schema-functions, Prev: sys-schema-procedures, Up: sys-schema-reference

26.4.5 sys Schema Stored Functions

The following sections describe *note 'sys': sys-schema. schema stored functions.

 File: manual.info.tmp, Node: sys-extract-schema-from-file-name, Next: sys-extract-table-from-file-name, Prev: sys-schema-functions, Up: sys-schema-functions

26.4.5.1 The extract_schema_from_file_name() Function .....................................................

Given a file path name, returns the path component that represents the schema name. This function assumes that the file name lies within the schema directory. For this reason, it does not work with partitions or tables defined using their own 'DATA_DIRECTORY' table option.

This function is useful when extracting file I/O information from the Performance Schema that includes file path names. It provides a convenient way to display schema names, which can be more easily understood than full path names, and can be used in joins against object schema names.

Parameters

Return Value

A 'VARCHAR(64)' value.

Example

 mysql> SELECT sys.extract_schema_from_file_name('/usr/local/mysql/data/world/City.ibd');
 +---------------------------------------------------------------------------+
 | sys.extract_schema_from_file_name('/usr/local/mysql/data/world/City.ibd') |
 +---------------------------------------------------------------------------+
 | world                                                                     |
 +---------------------------------------------------------------------------+

 File: manual.info.tmp, Node: sys-extract-table-from-file-name, Next: sys-format-bytes, Prev: sys-extract-schema-from-file-name, Up: sys-schema-functions

26.4.5.2 The extract_table_from_file_name() Function ....................................................

Given a file path name, returns the path component that represents the table name.

This function is useful when extracting file I/O information from the Performance Schema that includes file path names. It provides a convenient way to display table names, which can be more easily understood than full path names, and can be used in joins against object table names.

Parameters

Return Value

A 'VARCHAR(64)' value.

Example

 mysql> SELECT sys.extract_table_from_file_name('/usr/local/mysql/data/world/City.ibd');
 +--------------------------------------------------------------------------+
 | sys.extract_table_from_file_name('/usr/local/mysql/data/world/City.ibd') |
 +--------------------------------------------------------------------------+
 | City                                                                     |
 +--------------------------------------------------------------------------+

 File: manual.info.tmp, Node: sys-format-bytes, Next: sys-format-path, Prev: sys-extract-table-from-file-name, Up: sys-schema-functions

26.4.5.3 The format_bytes() Function ....................................

Given a byte count, converts it to human-readable format and returns a string consisting of a value and a units indicator. Depending on the size of the value, the units part is 'bytes', 'KiB' (kibibytes), 'MiB' (mebibytes), 'GiB' (gibibytes), 'TiB' (tebibytes), or 'PiB' (pebibytes).

Parameters

Return Value

A 'TEXT' value.

Example

 mysql> SELECT sys.format_bytes(512), sys.format_bytes(18446644073709551615);
 +-----------------------+----------------------------------------+
 | sys.format_bytes(512) | sys.format_bytes(18446644073709551615) |
 +-----------------------+----------------------------------------+
 | 512 bytes             | 16383.91 PiB                           |
 +-----------------------+----------------------------------------+

 File: manual.info.tmp, Node: sys-format-path, Next: sys-format-statement, Prev: sys-format-bytes, Up: sys-schema-functions

26.4.5.4 The format_path() Function ...................................

Given a path name, returns the modified path name after replacing subpaths that match the values of the following system variables, in order:

 datadir
 tmpdir
 slave_load_tmpdir
 innodb_data_home_dir
 innodb_log_group_home_dir
 innodb_undo_directory
 basedir

A value that matches the value of system variable SYSVAR is replaced with the string '@@GLOBAL.SYSVAR'.

Prior to MySQL 5.7.14, backslashes in Windows path names are converted to forward slashes in the result.

Parameters

Return Value

A 'VARCHAR(512) CHARACTER SET utf8' value.

Example

 mysql> SELECT sys.format_path('/usr/local/mysql/data/world/City.ibd');
 +---------------------------------------------------------+
 | sys.format_path('/usr/local/mysql/data/world/City.ibd') |
 +---------------------------------------------------------+
 | @@datadir/world/City.ibd                                |
 +---------------------------------------------------------+

 File: manual.info.tmp, Node: sys-format-statement, Next: sys-format-time, Prev: sys-format-path, Up: sys-schema-functions

26.4.5.5 The format_statement() Function ........................................

Given a string (normally representing an SQL statement), reduces it to the length given by the 'statement_truncate_len' configuration option, and returns the result. No truncation occurs if the string is shorter than 'statement_truncate_len'. Otherwise, the middle part of the string is replaced by an ellipsis ('...').

This function is useful for formatting possibly lengthy statements retrieved from Performance Schema tables to a known fixed maximum length.

Parameters

Configuration Options

note 'format_statement()': sys-format-statement. operation can be modified using the following configuration options or their corresponding user-defined variables (see note sys-sys-config::):

Return Value

A 'LONGTEXT' value.

Example

By default, *note 'format_statement()': sys-format-statement. truncates statements to be no more than 64 characters. Setting '@sys.statement_truncate_len' changes the truncation length for the current session:

 mysql> SET @stmt = 'SELECT variable, value, set_time, set_by FROM sys_config';
 mysql> SELECT sys.format_statement(@stmt);
 +----------------------------------------------------------+
 | sys.format_statement(@stmt)                              |
 +----------------------------------------------------------+
 | SELECT variable, value, set_time, set_by FROM sys_config |
 +----------------------------------------------------------+
 mysql> SET @sys.statement_truncate_len = 32;
 mysql> SELECT sys.format_statement(@stmt);
 +-----------------------------------+
 | sys.format_statement(@stmt)       |
 +-----------------------------------+
 | SELECT variabl ... ROM sys_config |
 +-----------------------------------+

 File: manual.info.tmp, Node: sys-format-time, Next: sys-list-add, Prev: sys-format-statement, Up: sys-schema-functions

26.4.5.6 The format_time() Function ...................................

Given a Performance Schema latency or wait time in picoseconds, converts it to human-readable format and returns a string consisting of a value and a units indicator. Depending on the size of the value, the units part is 'ps' (picoseconds), 'ns' (nanoseconds), 'us' (microseconds), 'ms' (milliseconds), 's' (seconds), 'm' (minutes), 'h' (hours), 'd' (days), or 'w' (weeks).

Parameters

Return Value

A 'TEXT' value.

Example

 mysql> SELECT sys.format_time(3501), sys.format_time(188732396662000);
 +-----------------------+----------------------------------+
 | sys.format_time(3501) | sys.format_time(188732396662000) |
 +-----------------------+----------------------------------+
 | 3.50 ns               | 3.15 m                           |
 +-----------------------+----------------------------------+

 File: manual.info.tmp, Node: sys-list-add, Next: sys-list-drop, Prev: sys-format-time, Up: sys-schema-functions

26.4.5.7 The list_add() Function ................................

Adds a value to a comma-separated list of values and returns the result.

This function and *note 'list_drop()': sys-list-drop. can be useful for manipulating the value of system variables such as 'sql_mode' and 'optimizer_switch' that take a comma-separated list of values.

Parameters

Return Value

A 'TEXT' value.

Example

 mysql> SELECT @@sql_mode;
 +----------------------------------------+
 | @@sql_mode                             |
 +----------------------------------------+
 | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES |
 +----------------------------------------+
 mysql> SET @@sql_mode = sys.list_add(@@sql_mode, 'NO_ENGINE_SUBSTITUTION');
 mysql> SELECT @@sql_mode;
 +---------------------------------------------------------------+
 | @@sql_mode                                                    |
 +---------------------------------------------------------------+
 | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
 +---------------------------------------------------------------+
 mysql> SET @@sql_mode = sys.list_drop(@@sql_mode, 'ONLY_FULL_GROUP_BY');
 mysql> SELECT @@sql_mode;
 +--------------------------------------------+
 | @@sql_mode                                 |
 +--------------------------------------------+
 | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
 +--------------------------------------------+

 File: manual.info.tmp, Node: sys-list-drop, Next: sys-ps-is-account-enabled, Prev: sys-list-add, Up: sys-schema-functions

26.4.5.8 The list_drop() Function .................................

Removes a value from a comma-separated list of values and returns the result. For more information, see the description of *note 'list_add()': sys-list-add.

Parameters

Return Value

A 'TEXT' value.

 File: manual.info.tmp, Node: sys-ps-is-account-enabled, Next: sys-ps-is-consumer-enabled, Prev: sys-list-drop, Up: sys-schema-functions

26.4.5.9 The ps_is_account_enabled() Function .............................................

Returns 'YES' or 'NO' to indicate whether Performance Schema instrumentation for a given account is enabled.

Parameters

Return Value

An 'ENUM('YES','NO')' value.

Example

 mysql> SELECT sys.ps_is_account_enabled('localhost', 'root');
 +------------------------------------------------+
 | sys.ps_is_account_enabled('localhost', 'root') |
 +------------------------------------------------+
 | YES                                            |
 +------------------------------------------------+

 File: manual.info.tmp, Node: sys-ps-is-consumer-enabled, Next: sys-ps-is-instrument-default-enabled, Prev: sys-ps-is-account-enabled, Up: sys-schema-functions

26.4.5.10 The ps_is_consumer_enabled() Function ...............................................

Returns 'YES' or 'NO' to indicate whether a given Performance Schema consumer is enabled, or 'NULL' if the argument is 'NULL'. If the argument is not a valid consumer name, an error occurs. (Prior to MySQL 5.7.28, the function returns 'NULL' if the argument is not a valid consumer name.)

This function accounts for the consumer hierarchy, so a consumer is not considered enabled unless all consumers on which depends are also enabled. For information about the consumer hierarchy, see *note performance-schema-consumer-filtering::.

Parameters

Return Value

An 'ENUM('YES','NO')' value.

Example

 mysql> SELECT sys.ps_is_consumer_enabled('thread_instrumentation');
 +------------------------------------------------------+
 | sys.ps_is_consumer_enabled('thread_instrumentation') |
 +------------------------------------------------------+
 | YES                                                  |
 +------------------------------------------------------+

 File: manual.info.tmp, Node: sys-ps-is-instrument-default-enabled, Next: sys-ps-is-instrument-default-timed, Prev: sys-ps-is-consumer-enabled, Up: sys-schema-functions

26.4.5.11 The ps_is_instrument_default_enabled() Function .........................................................

Returns 'YES' or 'NO' to indicate whether a given Performance Schema instrument is enabled by default.

Parameters

Return Value

An 'ENUM('YES','NO')' value.

Example

 mysql> SELECT sys.ps_is_instrument_default_enabled('memory/innodb/row_log_buf');
 +-------------------------------------------------------------------+
 | sys.ps_is_instrument_default_enabled('memory/innodb/row_log_buf') |
 +-------------------------------------------------------------------+
 | NO                                                                |
 +-------------------------------------------------------------------+
 mysql> SELECT sys.ps_is_instrument_default_enabled('statement/sql/alter_user');
 +------------------------------------------------------------------+
 | sys.ps_is_instrument_default_enabled('statement/sql/alter_user') |
 +------------------------------------------------------------------+
 | YES                                                              |
 +------------------------------------------------------------------+

 File: manual.info.tmp, Node: sys-ps-is-instrument-default-timed, Next: sys-ps-is-thread-instrumented, Prev: sys-ps-is-instrument-default-enabled, Up: sys-schema-functions

26.4.5.12 The ps_is_instrument_default_timed() Function .......................................................

Returns 'YES' or 'NO' to indicate whether a given Performance Schema instrument is timed by default.

Parameters

Return Value

An 'ENUM('YES','NO')' value.

Example

 mysql> SELECT sys.ps_is_instrument_default_timed('memory/innodb/row_log_buf');
 +-----------------------------------------------------------------+
 | sys.ps_is_instrument_default_timed('memory/innodb/row_log_buf') |
 +-----------------------------------------------------------------+
 | NO                                                              |
 +-----------------------------------------------------------------+
 mysql> SELECT sys.ps_is_instrument_default_timed('statement/sql/alter_user');
 +----------------------------------------------------------------+
 | sys.ps_is_instrument_default_timed('statement/sql/alter_user') |
 +----------------------------------------------------------------+
 | YES                                                            |
 +----------------------------------------------------------------+

 File: manual.info.tmp, Node: sys-ps-is-thread-instrumented, Next: sys-ps-thread-account, Prev: sys-ps-is-instrument-default-timed, Up: sys-schema-functions

26.4.5.13 The ps_is_thread_instrumented() Function ..................................................

Returns 'YES' or 'NO' to indicate whether Performance Schema instrumentation for a given connection ID is enabled, 'UNKNOWN' if the ID is unknown, or 'NULL' if the ID is 'NULL'.

Parameters

Return Value

An 'ENUM('YES','NO','UNKNOWN')' value.

Example

 mysql> SELECT sys.ps_is_thread_instrumented(43);
 +-----------------------------------+
 | sys.ps_is_thread_instrumented(43) |
 +-----------------------------------+
 | UNKNOWN                           |
 +-----------------------------------+
 mysql> SELECT sys.ps_is_thread_instrumented(CONNECTION_ID());
 +------------------------------------------------+
 | sys.ps_is_thread_instrumented(CONNECTION_ID()) |
 +------------------------------------------------+
 | YES                                            |
 +------------------------------------------------+

 File: manual.info.tmp, Node: sys-ps-thread-account, Next: sys-ps-thread-id, Prev: sys-ps-is-thread-instrumented, Up: sys-schema-functions

26.4.5.14 The ps_thread_account() Function ..........................................

Given a Performance Schema thread ID, returns the 'USER_NAME@HOST_NAME' account associated with the thread.

Parameters

Return Value

A 'TEXT' value.

Example

 mysql> SELECT sys.ps_thread_account(sys.ps_thread_id(CONNECTION_ID()));
 +----------------------------------------------------------+
 | sys.ps_thread_account(sys.ps_thread_id(CONNECTION_ID())) |
 +----------------------------------------------------------+
 | root@localhost                                           |
 +----------------------------------------------------------+

 File: manual.info.tmp, Node: sys-ps-thread-id, Next: sys-ps-thread-stack, Prev: sys-ps-thread-account, Up: sys-schema-functions

26.4.5.15 The ps_thread_id() Function .....................................

Returns the Performance Schema thread ID assigned to a given connection ID, or the thread ID for the current connection if the connection ID is 'NULL'.

Parameters

Return Value

A 'BIGINT UNSIGNED' value.

Example

 mysql> SELECT sys.ps_thread_id(260);
 +-----------------------+
 | sys.ps_thread_id(260) |
 +-----------------------+
 |                   285 |
 +-----------------------+

 File: manual.info.tmp, Node: sys-ps-thread-stack, Next: sys-ps-thread-trx-info, Prev: sys-ps-thread-id, Up: sys-schema-functions

26.4.5.16 The ps_thread_stack() Function ........................................

Returns a JSON formatted stack of all statements, stages, and events within the Performance Schema for a given thread ID.

Parameters

Return Value

A 'LONGTEXT CHARACTER SET latin1' value.

Example

 mysql> SELECT sys.ps_thread_stack(37, FALSE) AS thread_stack\G
 *************************** 1. row ***************************
 thread_stack: {"rankdir": "LR","nodesep": "0.10",
 "stack_created": "2014-02-19 13:39:03", "mysql_version": "5.7.3-m13",
 "mysql_user": "root@localhost","events": [{"nesting_event_id": "0",
 "event_id": "10", "timer_wait": 256.35, "event_info": "sql/select",
 "wait_info": "select @@version_comment limit 1\nerrors: 0\nwarnings: 0\nlock time:
 ...

 File: manual.info.tmp, Node: sys-ps-thread-trx-info, Next: sys-quote-identifier, Prev: sys-ps-thread-stack, Up: sys-schema-functions

26.4.5.17 The ps_thread_trx_info() Function ...........................................

Returns a JSON object containing information about a given thread. The information includes the current transaction, and the statements it has already executed, derived from the Performance Schema note 'events_transactions_current': performance-schema-events-transactions-current-table. and note 'events_statements_history': performance-schema-events-statements-history-table. tables. (The consumers for those tables must be enabled to obtain full data in the JSON object.)

If the output exceeds the truncation length (65535 by default), a JSON error object is returned, such as:

 { "error": "Trx info truncated: Row 6 was cut by GROUP_CONCAT()" }

Similar error objects are returned for other warnings and exceptions raised during function execution.

Parameters

Configuration Options

note 'ps_thread_trx_info()': sys-ps-thread-trx-info. operation can be modified using the following configuration options or their corresponding user-defined variables (see note sys-sys-config::):

Return Value

A 'LONGTEXT' value.

Example

 mysql> SELECT sys.ps_thread_trx_info(48)\G
 *************************** 1. row ***************************
 sys.ps_thread_trx_info(48): [
   {
     "time": "790.70 us",
     "state": "COMMITTED",
     "mode": "READ WRITE",
     "autocommitted": "NO",
     "gtid": "AUTOMATIC",
     "isolation": "REPEATABLE READ",
     "statements_executed": [
       {
         "sql_text": "INSERT INTO info VALUES (1, \'foo\')",
         "time": "471.02 us",
         "schema": "trx",
         "rows_examined": 0,
         "rows_affected": 1,
         "rows_sent": 0,
         "tmp_tables": 0,
         "tmp_disk_tables": 0,
         "sort_rows": 0,
         "sort_merge_passes": 0
       },
       {
         "sql_text": "COMMIT",
         "time": "254.42 us",
         "schema": "trx",
         "rows_examined": 0,
         "rows_affected": 0,
         "rows_sent": 0,
         "tmp_tables": 0,
         "tmp_disk_tables": 0,
         "sort_rows": 0,
         "sort_merge_passes": 0
       }
     ]
   },
   {
     "time": "426.20 us",
     "state": "COMMITTED",
     "mode": "READ WRITE",
     "autocommitted": "NO",
     "gtid": "AUTOMATIC",
     "isolation": "REPEATABLE READ",
     "statements_executed": [
       {
         "sql_text": "INSERT INTO info VALUES (2, \'bar\')",
         "time": "107.33 us",
         "schema": "trx",
         "rows_examined": 0,
         "rows_affected": 1,
         "rows_sent": 0,
         "tmp_tables": 0,
         "tmp_disk_tables": 0,
         "sort_rows": 0,
         "sort_merge_passes": 0
       },
       {
         "sql_text": "COMMIT",
         "time": "213.23 us",
         "schema": "trx",
         "rows_examined": 0,
         "rows_affected": 0,
         "rows_sent": 0,
         "tmp_tables": 0,
         "tmp_disk_tables": 0,
         "sort_rows": 0,
         "sort_merge_passes": 0
       }
     ]
   }
 ]

 File: manual.info.tmp, Node: sys-quote-identifier, Next: sys-sys-get-config, Prev: sys-ps-thread-trx-info, Up: sys-schema-functions

26.4.5.18 The quote_identifier() Function .........................................

Given a string argument, this function produces a quoted identifier suitable for inclusion in SQL statements. This is useful when a value to be used as an identifier is a reserved word or contains backtick ('`') characters. It was added in MySQL 5.7.14.

Parameters

'in_identifier TEXT': The identifier to quote.

Return Value

A 'TEXT' value.

Example

 mysql> SELECT sys.quote_identifier('plain');
 +-------------------------------+
 | sys.quote_identifier('plain') |
 +-------------------------------+
 | `plain`                       |
 +-------------------------------+
 mysql> SELECT sys.quote_identifier('trick`ier');
 +-----------------------------------+
 | sys.quote_identifier('trick`ier') |
 +-----------------------------------+
 | `trick``ier`                      |
 +-----------------------------------+
 mysql> SELECT sys.quote_identifier('integer');
 +---------------------------------+
 | sys.quote_identifier('integer') |
 +---------------------------------+
 | `integer`                       |
 +---------------------------------+

 File: manual.info.tmp, Node: sys-sys-get-config, Next: sys-version-major, Prev: sys-quote-identifier, Up: sys-schema-functions

26.4.5.19 The sys_get_config() Function .......................................

Given a configuration option name, returns the option value from the *note 'sys_config': sys-sys-config. table, or the provided default value (which may be 'NULL') if the option does not exist in the table.

If *note 'sys_get_config()': sys-sys-get-config. returns the default value and that value is 'NULL', it is expected that the caller is able to handle 'NULL' for the given configuration option.

By convention, routines that call note 'sys_get_config()': sys-sys-get-config. first check whether the corresponding user-defined variable exists and is non-'NULL'. If so, the routine uses the variable value without reading the note 'sys_config': sys-sys-config. table. If the variable does not exist or is 'NULL', the routine reads the option value from the table and sets the user-defined variable to that value. For more information about the relationship between configuration options and their corresponding user-defined variables, see *note sys-sys-config::.

If you want to check whether the configuration option has already been set and, if not, use the return value of 'sys_get_config()', you can use 'IFNULL(...)' (see example later). However, this should not be done inside a loop (for example, for each row in a result set) because for repeated calls where the assignment is needed only in the first iteration, using 'IFNULL(...)' is expected to be significantly slower than using an 'IF (...) THEN ... END IF;' block (see example later).

Parameters

Return Value

A 'VARCHAR(128)' value.

Example

Get a configuration value from the *note 'sys_config': sys-sys-config. table, falling back to 128 as the default if the option is not present in the table:

 mysql> SELECT sys.sys_get_config('statement_truncate_len', 128) AS Value;
 +-------+
 | Value |
 +-------+
 | 64    |
 +-------+

One-liner example: Check whether the option is already set; if not, assign the 'IFNULL(...)' result (using the value from the *note 'sys_config': sys-sys-config. table):

 mysql> SET @sys.statement_truncate_len =
        IFNULL(@sys.statement_truncate_len,
               sys.sys_get_config('statement_truncate_len', 64));

'IF (...) THEN ... END IF;' block example: Check whether the option is already set; if not, assign the value from the *note 'sys_config': sys-sys-config. table:

 IF (@sys.statement_truncate_len IS NULL) THEN
   SET @sys.statement_truncate_len = sys.sys_get_config('statement_truncate_len', 64);
 END IF;

 File: manual.info.tmp, Node: sys-version-major, Next: sys-version-minor, Prev: sys-sys-get-config, Up: sys-schema-functions

26.4.5.20 The version_major() Function ......................................

This function returns the major version of the MySQL server.

Parameters

None.

Return Value

A 'TINYINT UNSIGNED' value.

Example

 mysql> SELECT VERSION(), sys.version_major();
 +------------------+---------------------+
 | VERSION()        | sys.version_major() |
 +------------------+---------------------+
 | 5.7.24-debug-log |                   5 |
 +------------------+---------------------+

 File: manual.info.tmp, Node: sys-version-minor, Next: sys-version-patch, Prev: sys-version-major, Up: sys-schema-functions

26.4.5.21 The version_minor() Function ......................................

This function returns the minor version of the MySQL server.

Parameters

None.

Return Value

A 'TINYINT UNSIGNED' value.

Example

 mysql> SELECT VERSION(), sys.version_minor();
 +------------------+---------------------+
 | VERSION()        | sys.version_minor() |
 +------------------+---------------------+
 | 5.7.24-debug-log |                   7 |
 +------------------+---------------------+

 File: manual.info.tmp, Node: sys-version-patch, Prev: sys-version-minor, Up: sys-schema-functions

26.4.5.22 The version_patch() Function ......................................

This function returns the patch release version of the MySQL server.

Parameters

None.

Return Value

A 'TINYINT UNSIGNED' value.

Example

 mysql> SELECT VERSION(), sys.version_patch();
 +------------------+---------------------+
 | VERSION()        | sys.version_patch() |
 +------------------+---------------------+
 | 5.7.24-debug-log |                  24 |
 +------------------+---------------------+

 File: manual.info.tmp, Node: connectors-apis, Next: mysql-enterprise, Prev: sys-schema, Up: Top

27 Connectors and APIs **********************

MySQL Connectors provide connectivity to the MySQL server for client programs. APIs provide low-level access to MySQL resources using either the classic MySQL protocol or X Protocol. Both Connectors and the APIs enable you to connect and execute MySQL statements from another language or environment, including ODBC, Java (JDBC), C++, Python, PHP, Perl, Ruby, and native C and embedded MySQL instances.

MySQL Connectors

Oracle develops a number of connectors:

The MySQL C API

For direct access to using MySQL natively within a C application, there are two methods:

See also MySQL C API Implementations (https://dev.mysql.com/doc/c-api/5.7/en/c-api-implementations.html).

To access MySQL from a C application, or to build an interface to MySQL for a language not supported by the Connectors or APIs in this chapter, the C API (https://dev.mysql.com/doc/c-api/5.7/en/) is where to start. A number of programmer's utilities are available to help with the process; see *note programs-development::.

Third-Party MySQL APIs

The remaining APIs described in this chapter provide an interface to MySQL from specific application languages. These third-party solutions are not developed or supported by Oracle. Basic information on their usage and abilities is provided here for reference purposes only.

All the third-party language APIs are developed using one of two methods, using 'libmysqlclient' or by implementing a native driver. The two solutions offer different benefits:

*note connectors-apis-summary:: lists many of the libraries and interfaces available for MySQL.

MySQL APIs and Interfaces

EnvironmentAPI Type Notes

Ada

GNU 'libmysqlclient' See MySQL Ada Bindings MySQL for GNU Bindings Ada (http://gnade.sourceforge.net/)

C

C API 'libmysqlclient' See MySQL 5.7 C API Developer Guide (https://dev.mysql.com/doc/c-api/5.7/en/).

C++

Connector/C++'libmysqlclient' See MySQL Connector/C++ 9.3 Developer Guide (https://dev.mysql.com/doc/connector-cpp/9.3/en/).

MySQL++ 'libmysqlclient' See MySQL++ website (http://tangentsoft.net/mysql++/doc/).

MySQL 'libmysqlclient' See MySQL wrapped wrapped (http://www.alhem.net/project/mysql/).

Cocoa

MySQL-Cocoa'libmysqlclient' Compatible with the Objective-C Cocoa environment. See http://mysql-cocoa.sourceforge.net/

D

MySQL 'libmysqlclient' See MySQL for D for D (http://www.steinmole.de/d/).

Eiffel

Eiffel 'libmysqlclient' See MySQL *note apis-eiffel::.

Erlang

'erlang-mysql-driver''libmysqlclient'See 'erlang-mysql-driver'. (http://code.google.com/p/erlang-mysql-driver/)

Haskell

Haskell Native Driver See Brian MySQL O'Sullivan's Bindings pure Haskell MySQL bindings (http://www.serpentine.com/blog/software/mysql/).

'hsql-mysql''libmysqlclient' See MySQL driver for Haskell (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsql-mysql-1.7).

Java/JDBC

Connector/JNative Driver See MySQL Connector/J Developer Guide (https://dev.mysql.com/doc/connector-j/en/).

Kaya

MyDB 'libmysqlclient' See MyDB (http://kayalang.org/library/latest/MyDB).

Lua

LuaSQL 'libmysqlclient' See LuaSQL (http://keplerproject.github.io/luasql/doc/us/).

.NET/Mono

Connector/NETNative Driver See MySQL Connector/NET Developer Guide (https://dev.mysql.com/doc/connector-net/en/).

Objective Caml

OBjective'libmysqlclient' See MySQL Caml Bindings MySQL for Bindings Objective Caml (http://raevnos.pennmush.org/code/ocaml-mysql/).

Octave

Database'libmysqlclient' See bindings Database for bindings GNU for GNU Octave Octave (http://octave.sourceforge.net/database/index.html).

ODBC

Connector/ODBC'libmysqlclient' See MySQL Connector/ODBC Developer Guide (https://dev.mysql.com/doc/connector-odbc/en/).

Perl

'DBI'/'DBD::mysql''libmysqlclient'See *note apis-perl::.

'Net::MySQL'Native Driver See 'Net::MySQL' (http://search.cpan.org/dist/Net-MySQL/MySQL.pm) at CPAN

PHP

'mysql','libmysqlclient' See MySQL 'ext/mysql' and PHP interface (https://dev.mysql.com/doc/apis-php/en/). (deprecated)

'mysqli','libmysqlclient' See MySQL 'ext/mysqli' and PHP interface (https://dev.mysql.com/doc/apis-php/en/).

'PDO_MYSQL''libmysqlclient' See MySQL and PHP (https://dev.mysql.com/doc/apis-php/en/).

PDO Native Driver mysqlnd

Python

Connector/PythonNative Driver See MySQL Connector/Python Developer Guide (https://dev.mysql.com/doc/connector-python/en/).

Python

Connector/Python'libmysqlclient' See MySQL C Connector/Python Extension Developer Guide (https://dev.mysql.com/doc/connector-python/en/).

MySQLdb 'libmysqlclient' See *note apis-python::.

Ruby

mysql2 'libmysqlclient' Uses 'libmysqlclient'. See *note apis-ruby::.

Scheme

'Myscsh''libmysqlclient' See 'Myscsh' (https://github.com/aehrisch/myscsh).

SPL

'sql_mysql''libmysqlclient' See 'sql_mysql' for SPL (http://www.clifford.at/spl/spldoc/sql_mysql.html).

Tcl

MySQLtcl'libmysqlclient' See *note apis-tcl::.

 File: manual.info.tmp, Node: connector-cpp-info, Next: connector-j-info, Prev: connectors-apis, Up: connectors-apis