blks_written
SLRU blocks writtenInterface Metrics (2)
About this metric
The block_write metric tracks the number of blocks written to disk from PostgreSQL's SLRU (Simple Least Recently Used) caches, as reported by the blks_written statistic in the pg_stat_slru system view. SLRU caches manage various internal PostgreSQL structures including commit logs (pg_clog/pg_xact), subtransaction logs (pg_subtrans), multixact members and offsets, and notification queues. When these in-memory cache buffers are evicted or flushed, the modified blocks must be written to persistent storage, and this metric captures the cumulative count of such write operations. Understanding SLRU write activity is operationally significant because excessive writes can indicate memory pressure, suboptimal cache sizing, or transaction patterns that generate high metadata overhead, potentially impacting overall database performance and I/O subsystem load.
From a performance and reliability perspective, monitoring block_write helps identify when SLRU caches are undersized or when workload patterns create unusual pressure on transaction metadata management. Healthy patterns typically show relatively steady, moderate write rates that correlate with transaction volume, while sudden spikes or sustained increases may signal issues such as long-running transactions causing subtransaction accumulation, high numbers of concurrent transactions exceeding cache capacity, or vacuum operations processing large backlogs. This metric is particularly valuable when analyzed alongside blks_read from the same view and traditional I/O metrics, as a high ratio of writes relative to hits suggests the cache is thrashing or insufficiently sized. Troubleshooting scenarios include investigating performance degradation during peak transaction periods, diagnosing unexplained I/O saturation, and right-sizing PostgreSQL memory configuration parameters. For cost management in cloud environments, tracking SLRU write patterns can help optimize provisioned IOPS and identify opportunities to reduce storage costs by addressing inefficient transaction patterns or tuning cache settings according to the PostgreSQL resource consumption documentation.
Available Content
Understanding PostgreSQL's block write behavior is critical for diagnosing performance bottlenecks and storage issues in production databases. When blocks aren't being written efficiently, you may experience everything from degraded query performance to transaction log bloat—but pinpointing the root cause requires deep expertise in PostgreSQL internals, particularly around autovacuum operations and their interaction with the buffer cache.
Our curated knowledge base connects block_write metrics directly to expert troubleshooting guidance from the PostgreSQL community, including proven diagnostic techniques for autovacuum-related write patterns that can silently degrade your database performance. You'll gain access to actionable tips that go beyond surface-level monitoring, helping you understand why your blocks are being written the way they are and exactly what to do about it. Sign up to unlock the full troubleshooting playbook that experienced SREs use to keep their PostgreSQL clusters running smoothly.