Skip to content

InnoDB buffer pool hit ratio

Share of page reads served from memory. Below 99% on a busy server means the buffer pool is smaller than the working set.

MySQL · SQL
SELECT ROUND(100 * (1 - disk.v / NULLIF(mem.v, 0)), 2) AS hit_pct,       mem.v AS read_requests,       disk.v AS disk_readsFROM (SELECT CAST(variable_value AS UNSIGNED) AS v FROM performance_schema.global_status WHERE variable_name = 'Innodb_buffer_pool_read_requests') mem,     (SELECT CAST(variable_value AS UNSIGNED) AS v FROM performance_schema.global_status WHERE variable_name = 'Innodb_buffer_pool_reads') disk

This query is part of the "MySQL health" pack: connect the database in DataRunner and install the whole pack at once, with queries and dashboard.

What the query shows

This query returns the share of InnoDB page reads served from memory. It takes two counters from performance_schema.global_status: Innodb_buffer_pool_read_requests (logical reads) and Innodb_buffer_pool_reads (reads that had to go to disk). The hit ratio is 100 times one minus disk reads divided by read requests.

Run it when queries slow down as data grows, when disk reads are high, or before you decide how much RAM the database needs.

How to read each column

  • hit_pct: the hit ratio, with two decimals.
  • read_requests: all logical page reads since startup.
  • disk_reads: the reads the buffer pool could not satisfy from memory.

Both counters are cumulative since startup, so the ratio is an average over the life of the server. A server that ran fine for a month and has a bad hour will hide it.

What is normal and what is not

These are rules of thumb, not MySQL limits:

  • 99 percent and above on a busy server is healthy.
  • 95 to 99 percent: worth watching, especially if it is falling over weeks.
  • Below 95 percent on a busy server usually means the buffer pool is smaller than the working set and the disk is doing the work.
  • Right after a restart the pool is cold and the ratio is low. Wait before judging it.
  • A small, idle database can show a low ratio simply because there are few reads. Look at disk_reads, not only the percentage.

What to do about it

The main lever is innodb_buffer_pool_size. On a server dedicated to MySQL, a common starting point is 50 to 75 percent of the RAM, leaving room for the operating system and per-connection memory. You can resize it online since MySQL 5.7.5:

-- 12 GB
SET GLOBAL innodb_buffer_pool_size = 12 * 1024 * 1024 * 1024;

-- Follow the resize:
SHOW STATUS LIKE 'Innodb_buffer_pool_resize_status';

MySQL rounds the value to a multiple of innodb_buffer_pool_chunk_size times innodb_buffer_pool_instances. Resizing happens in the background in chunks, and it is best done in a quiet period. Put the final value in my.cnf.

To judge the current rate and not the average, read the two counters twice, a few minutes apart, and apply the same formula to the differences.

Limits of this query

  • It covers InnoDB only. MyISAM tables use the key cache instead.
  • The ratio since startup hides recent changes. Compare snapshots over time.
  • A high ratio does not prove the pool is the right size. Tables that are scanned once and never read again can distort it. Also check the buffer pool in SHOW ENGINE INNODB STATUS.
  • A very low ratio can also come from missing indexes that force big scans. Check the slowest statements before adding RAM.
  • MySQL 8.0 and MariaDB expose the counters through performance_schema.global_status or SHOW GLOBAL STATUS. If the performance_schema is off, read them from SHOW GLOBAL STATUS.

Watch the trend in DataRunner

Schedule the query once a day and send it to Google Sheets, e-mail or Slack. A falling ratio over weeks tells you to add memory before users notice. To be told only when it gets bad, wrap the query as SELECT * FROM (...) t WHERE hit_pct < 99 and skip runs with no rows. WhatsApp (beta), Telegram, Discord and a signed webhook are also available.

Frequently asked questions

What is a good InnoDB buffer pool hit ratio?
On a busy server, 99 percent or more is the usual target. Below 95 percent, the working set probably does not fit in memory. A cold pool after a restart and a nearly idle server are two exceptions.
How do I calculate the buffer pool hit ratio in MySQL?
Take Innodb_buffer_pool_reads and Innodb_buffer_pool_read_requests from the global status. The ratio is 100 times (1 minus reads divided by read requests). The query on this page returns that value and both counters.
How big should innodb_buffer_pool_size be?
On a server used only for MySQL, start at 50 to 75 percent of RAM and adjust based on the hit ratio and on free memory. Leave room for the operating system and for per-connection memory.
Can I change innodb_buffer_pool_size without restarting MySQL?
Yes, from MySQL 5.7.5. SET GLOBAL resizes it in the background, in chunks. Do it in a quiet period and watch Innodb_buffer_pool_resize_status.