Technologies/PostgreSQL/blks_written
PostgreSQLPostgreSQLMetric

blks_written

SLRU blocks written
Dimensions:None
Available on:Native (1)DatadogDatadog (1)
Interface Metrics (2)
Native
blks_written statistic from pg_stat_slru
Dimensions:None
DatadogDatadog
Number of disk blocks written for SLRU (simple least-recently-used) cache. SLRU caches are created with a fixed number of pages. When all pages are used, the least recently used block is dumped on disk to create space. A block eviction doesn't necessarily generate disk write as the block could have been written in a previous eviction. This metric is tagged with slru_name.
Dimensions:None

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.

Knowledge Base (1 documents, 0 chunks)
troubleshootingDebugging Postgres autovacuum problems: 13 tips - Citus Data3048 wordsscore: 0.75This blog post provides detailed troubleshooting guidance for PostgreSQL autovacuum problems, covering 13 tips to diagnose and fix issues where autovacuum doesn't trigger often enough, runs too slowly, or fails to clean up dead rows. It explains how to use pg_stat_user_tables and pg_stat_progress_vacuum to monitor vacuum operations and provides specific tuning recommendations for autovacuum configuration parameters.