The group of views that relate to performance are those that you will likely use the most in your performance tuning work together with the COLUMN_STATISTICS and STATISTICS views from the previous group of views. The views with performance-related information are listed in Table 7-3.
122
Table 7-3. Information Schema views with performance-related information
View Name Description
INNODB_BUFFER_PAGE A list of the pages in the InnoDB buffer pool which can be used to determine which tables and indexes are currently cached.
Warning: There is a high overhead of querying this table particularly for large buffer pools and many tables and indexes. It is best used on test systems.
INNODB_BUFFER_PAGE_LRU Information about the pages in the InnoDB buffer pool and how they are ordered in the least recently used (LrU) list.
Warning: There is a high overhead of querying this table particularly for large buffer pools and many tables and indexes. It is best used on test systems.
INNODB_BUFFER_POOL_STATS Statistics about the usage of the InnoDB buffer pool. The information is similar to what can be found in the SHOW ENGINE INNODB STATUS output in the BUFFER POOL AND MEMORY section. This is one of the most useful views.
INNODB_CACHED_INDEXES A summary of the number of index pages cached in the InnoDB buffer pool for each index.
INNODB_CMP INNODB_CMP_RESET
Statistics about operations related to compressed InnoDB tables.
INNODB_CMP_PER_INDEX INNODB_CMP_PER_INDEX_RESET
The same as INNODB_CMP but grouped by the index.
INNODB_CMPMEM INNODB_CMPMEM_RESET
Statistics about compressed pages in the InnoDB buffer pool.
INNODB_METRICS Similar to the global status variables but specific to InnoDB.
INNODB_SESSION_TEMP_
TABLESPACES
Metadata including the connection id, file path, and size for InnoDB temporary tablespace files (each session gets its own file in MySQL 8.0.13 and later). It can be used to link a session to a tablespace file which is very useful if you notice one file becoming large. The view was added in 8.0.13.
(continued)
ChApTer 7 The InForMATIon SCheMA
View Name Description
INNODB_TRX Information about InnoDB transactions.
OPTIMIZER_TRACE When the optimizer trace is enabled, the trace can be queried from this view.
PROCESSLIST The same as SHOW PROCESSLIST.
PROFILING When profiling is enabled, the profiling statistics can be queried from this view. This is deprecated, and it is recommended to use the performance Schema instead.
Table 7-3. (continued)
For the views with information about InnoDB compressed tables, the table with _ RESET as the suffix returns the operation and timing statistics as deltas since the last time the view was queried.
The INNODB_METRICS view includes metrics similar to the global status variables but specific to InnoDB. The metrics are grouped into subsystems (the SUBSYSTEM column), and for each metric there is a description of what the metric measures in the COMMENT column. You can enable, disable, and reset the metrics using global system variables:
• innodb_monitor_disable: Disable one or more metrics.
• innodb_monitor_enable: Enable one or more metrics.
• innodb_monitor_reset: Reset the counter for one or more metrics.
• innodb_monitor_reset_all: Reset all statistics including the counter, minimum, and maximum values for one or more metrics.
The metrics can be turned on and off as needed with the current status found in the STATUS column. You specify the name of the metric as the value to the innodb_monitor_
enable or innodb_monitor_disable variable, and you can use % as a wildcard. The value all works as a special value to affect all metrics. Listing 7-1 shows an example of enabling and using all the metrics matching %cpu% (which happens to be the metrics in the cpu subsystem). The counter values depend on the workload you have at the time of the query.
124
Listing 7-1. Using the INNODB_METRICS view
mysql> SET GLOBAL innodb_monitor_enable = '%cpu%';
Query OK, 0 rows affected (0.0005 sec) mysql> SELECT NAME, COUNT, MIN_COUNT, MAX_COUNT, AVG_COUNT, STATUS, COMMENT
FROM information_schema.INNODB_METRICS WHERE NAME LIKE '%cpu%'\G
*************************** 1. row ***************************
NAME: module_cpu COUNT: 0
MIN_COUNT: NULL MAX_COUNT: NULL AVG_COUNT: 0 STATUS: enabled
COMMENT: CPU counters reflecting current usage of CPU
*************************** 2. row ***************************
NAME: cpu_utime_abs COUNT: 51
MIN_COUNT: 0 MAX_COUNT: 51
AVG_COUNT: 0.4358974358974359 STATUS: enabled
COMMENT: Total CPU user time spent
*************************** 3. row ***************************
NAME: cpu_stime_abs COUNT: 7
MIN_COUNT: 0 MAX_COUNT: 7
AVG_COUNT: 0.05982905982905983 STATUS: enabled
COMMENT: Total CPU system time spent ChApTer 7 The InForMATIon SCheMA
*************************** 4. row ***************************
NAME: cpu_utime_pct COUNT: 6
MIN_COUNT: 0 MAX_COUNT: 6
AVG_COUNT: 0.05128205128205128 STATUS: enabled
COMMENT: Relative CPU user time spent
*************************** 5. row ***************************
NAME: cpu_stime_pct COUNT: 0
MIN_COUNT: 0 MAX_COUNT: 0 AVG_COUNT: 0 STATUS: enabled
COMMENT: Relative CPU system time spent
*************************** 6. row ***************************
NAME: cpu_n COUNT: 8 MIN_COUNT: 8 MAX_COUNT: 8
AVG_COUNT: 0.06837606837606838 STATUS: enabled
COMMENT: Number of cpus 6 rows in set (0.0011 sec)
mysql> SET GLOBAL innodb_monitor_disable = '%cpu%';
Query OK, 0 rows affected (0.0004 sec)
First, the metrics are enabled using the innodb_monitor_enable variable; then the values are retrieved. In addition to the values shown, there is also a set of columns with the _RESET suffix which are reset when you set the innodb_monitor_reset (only the counter) or innodb_monitor_reset_all system variable. Finally, the metrics are disabled again.
126