Technologies/PostgreSQL/postgresql.blocks_hit
PostgreSQLPostgreSQLMetric

postgresql.blocks_hit

Buffer cache hits
Dimensions:None
Available on:Native (1)DatadogDatadog (1)
Interface Metrics (2)
Native
Number of buffer hits (blocks found in cache)
Dimensions:None
DatadogDatadog
Total number of shared block cache hits per query_signature, db, and user. (DBM only)
Dimensions:None

Technical Annotations (21)

Configuration Parameters (3)
shared_buffers
size of PostgreSQL buffer cache in memory
effective_cache_sizerecommended: 50-75% of total RAM
planner estimate of OS and PostgreSQL cache
enable_seqscanrecommended: false
Session-level override to force index usage when sequential scans perform poorly
CLI Commands (7)
SELECT sum(blks_hit) * 100.0 / sum(blks_hit + blks_read) as buffer_hit_ratio FROM pg_stat_database;diagnostic
SELECT relname, heap_blks_hit * 100.0 / nullif(heap_blks_hit + heap_blks_read, 0) as hit_ratio FROM pg_statio_user_tables WHERE heap_blks_read > 0 ORDER BY hit_ratio;diagnostic
SELECT pg_reload_conf();remediation
SELECT round(blks_hit*100/(blks_hit+blks_read), 2) AS cache_hit_ratio FROM pg_stat_database WHERE datname = current_database();diagnostic
ALTER SYSTEM SET shared_buffers = '16GB';remediation
EXPLAINdiagnostic
set enable_seqscan = false;remediation
Technical References (11)
shared_bufferscomponentpg_stat_databasecomponentpg_statio_user_tablescomponentOS Page CachecomponentCache Hit Ratioconceptdead tuplesconceptbuffer hitsconceptshared bufferscomponentpg_buffercachecomponentpg_prewarmcomponentcache hit ratioconcept
Related Insights (10)
Cache hit ratio below optimal causes excessive disk I/Owarning
Low buffer hit ratio indicates insufficient shared_buffers or cache pressurewarning
Insufficient shared_buffers causes excessive disk reads and slow querieswarning
Insufficient shared_buffers limits PostgreSQL cache effectivenesswarning
Cache hit ratio below 99% indicates undersized shared_buffers or high disk I/Owarning
Slow queries caused by dead tuples, invalid queries, or misconfigurationwarning
Insufficient shared_buffers causes excessive disk I/Owarning
Sequential scans load entire table into shared buffers memory areainfo
Cold buffer cache causes dramatic sequential scan performance degradationwarning
Cache hit ratio below 99% indicates insufficient shared_buffers memorywarning