denrepo

PostgreSQLPerformance

Buffer cache hit ratio per database

Share of block reads served from shared buffers. OLTP databases usually sit above 99%; a drop suggests memory pressure or a new large scan.

Not yet verified. How scripts are tested

b-pg-cache.sql
1SELECT datname,2       round(100.0 * blks_hit / NULLIF(blks_hit + blks_read, 0), 2) AS cache_hit_pct3FROM pg_stat_database4WHERE datname IS NOT NULL5ORDER BY cache_hit_pct;

Paste it into your query tool.

Open in denrepo

More PostgreSQL scripts: Performance