Databases 9 min read

Simplifying MySQL InnoDB Status Metrics with the innodb_metrics Table

This article explains how to use the MySQL innodb_metrics table to transform the unreadable output of the show engine innodb status command into clear, queryable metrics, including buffer pool statistics and CPU counters, and shows how to enable or disable specific counters as needed.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Simplifying MySQL InnoDB Status Metrics with the innodb_metrics Table

For MySQL users familiar with the show engine innodb status command, the raw output is often difficult to read; this article demonstrates how to simplify and make it more readable by leveraging the innodb_metrics system table.

The innodb_metrics table, located in the metadata dictionary, records all internal InnoDB counters; MySQL 8.0.31 includes 314 such modules.

<mysql:8.0.31:information_schema>select count(*) as metrics_module_total from innodb_metrics;
+----------------------+
| metrics_module_total |
+----------------------+
|                  314 |
+----------------------+
1 row in set (0.00 sec)

Key counters such as buffer pool size, free buffers, and database pages can be queried directly from this table, converting raw page counts into megabytes for easier interpretation.

mysql:8.0.31:information_schema>select name,concat(truncate(max_count/1024/1024,2),' MB') innodb_buffer_pool_size from innodb_metrics where name ='buffer_pool_size';
+------------------+-------------------------+
| name             | innodb_buffer_pool_size |
+------------------+-------------------------+
| buffer_pool_size | 128.00 MB               |
+------------------+-------------------------+
1 row in set (0.00 sec)
<mysql:8.0.31:information_schema>select name,concat(truncate(max_count/1024/1024,2),' MB') 'databases_pages_size' from innodb_metrics where name  = 'buffer_pool_bytes_data';
+------------------------+----------------------+
| name                   | databases_pages_size |
+------------------------+----------------------+
| buffer_pool_bytes_data | 16.28 MB             |
+------------------------+----------------------+
1 row in set (0.00 sec)
mysql:8.0.31:information_schema>select name,concat(truncate(max_count*16/1024,2),' MB') 'free buffers size' from innodb_metrics where name  ='buffer_pool_pages_free';
+------------------------+-------------------+
| name                   | free buffers size |
+------------------------+-------------------+
| buffer_pool_pages_free | 111.62 MB         |
+------------------------+-------------------+
1 row in set (0.00 sec)

These counters are enabled by default for the show engine innodb status output (status = 'enabled'), while many other counters remain disabled to avoid performance impact.

<mysql:8.0.31:information_schema>select count(*) from innodb_metrics where status='enabled';
+----------+
| count(*) |
+----------+
|       74 |
+----------+
1 row in set (0.00 sec)

To monitor CPU-related counters, they must be manually enabled using the innodb_monitor_enable variable, after which their values become queryable.

mysql:8.0.31:information_schema>set global innodb_monitor_enable='cpu_n'; -- total CPU cores
Query OK, 0 rows affected (0.00 sec)
<mysql:8.0.31:information_schema>set global innodb_monitor_enable='cpu_utime_abs'; -- user CPU time
Query OK, 0 rows affected (0.00 sec)
<mysql:8.0.31:information_schema>set global innodb_monitor_enable='cpu_stime_abs'; -- system CPU time
Query OK, 0 rows affected (0.00 sec)

After enabling, the counters can be retrieved with a simple SELECT, and later disabled again with innodb_monitor_disable when no longer needed.

<mysql:8.0.31:information_schema>select name,max_count,comment, status from innodb_metrics where name in ('cpu_n','cpu_utime_abs','cpu_stime_abs');
+---------------+-----------+-----------------------------+---------+
| name          | max_count | comment                     | status  |
+---------------+-----------+-----------------------------+---------+
| cpu_utime_abs |       106 | Total CPU user time spent   | enabled |
| cpu_stime_abs |         1 | Total CPU system time spent | enabled |
| cpu_n         |        32 | Number of cpus              | enabled |
+---------------+-----------+-----------------------------+---------+
3 rows in set (0.00 sec)
mysql:8.0.31:information_schema>set global innodb_monitor_disable='cpu_stime_abs';
Query OK, 0 rows affected (0.00 sec)
<mysql:8.0.31:information_schema>set global innodb_monitor_disable='cpu_utime_abs';
Query OK, 0 rows affected (0.00 sec)
<mysql:8.0.31:information_schema>set global innodb_monitor_disable='cpu_n';
Query OK, 0 rows affected (0.00 sec)

By querying innodb_metrics , administrators can obtain readable, metric‑based insights into InnoDB performance without parsing the verbose text output of show engine innodb status .

PerformanceSQLmetricsInnoDBMySQLDatabase Monitoring
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.