Skip to content

PopSQL: limited support.

Migrate now →

Cache hit ratio

Share of reads served from shared buffers, for tables and for indexes. Below 99% on a warm OLTP server means the working set no longer fits.

PostgreSQL · SQL
SELECT 'tables' AS kind,
       ROUND(100.0 * SUM(heap_blks_hit) / NULLIF(SUM(heap_blks_hit) + SUM(heap_blks_read), 0), 2) AS hit_pct
FROM pg_statio_user_tables
UNION ALL
SELECT 'indexes',
       ROUND(100.0 * SUM(idx_blks_hit) / NULLIF(SUM(idx_blks_hit) + SUM(idx_blks_read), 0), 2)
FROM pg_statio_user_indexes

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