Script #27
mysql
Monitoringread-onlyMin Version: 5.7MySQL InnoDB Buffer Pool Hit Ratio
Compares buffer pool read requests against disk reads to compute the hit ratio. Tells you whether memory sizing is sufficient.
#innodb#buffer-pool#cache-hit
mysql · sql
SELECT
(SELECT variable_value FROM performance_schema.global_status WHERE variable_name='Innodb_buffer_pool_read_requests') AS read_requests,
(SELECT variable_value FROM performance_schema.global_status WHERE variable_name='Innodb_buffer_pool_reads') AS disk_reads,
ROUND(100 * (1 -
(SELECT variable_value FROM performance_schema.global_status WHERE variable_name='Innodb_buffer_pool_reads') /
NULLIF((SELECT variable_value FROM performance_schema.global_status WHERE variable_name='Innodb_buffer_pool_read_requests'), 0)
), 3) AS hit_ratio_pct;Operational Notes & Remediation Guidance
Target is 99%+ in OLTP environments. Lower ratios indicate memory pressure or poorly indexed queries evicting hot pages.
Production Safety & Execution Standards
- This script is designed for read-only diagnostics; it does not alter schema or modify data directly.
- Prior to executing on production systems under high load, verify the target database version (Min. Version: 5.7).
- Exercise caution with mutating actions (e.g., terminating sessions or dropping indexes) referenced in the notes section.
Other MYSQL Diagnostic Scripts
View All (100)#21Performance
Find Long-Running Queries in MySQL
Lists active queries running longer than 60 seconds from the processlist. Fast diagnosis for slowdowns and lock pile-ups.
View Script
#22Locking
Find MySQL InnoDB Lock Waits and the Blocking Query
Uses the sys schema to show waiting and blocking sessions with lock modes. Resolves who is holding up whom in a single query.
View Script
#23Storage
List the Largest Tables and Disk Usage in MySQL
Ranks tables by data, index and free space size. Core input for capacity planning and archiving decisions.
View Script
#24Performance
Detect Unused Indexes in MySQL
Uses sys.schema_unused_indexes to list indexes that were never used. Helps safely drop indexes that slow down writes.
View Script