<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Pg_stat_checkpointer on Postgres Scripts</title><link>https://www.postgresscripts.com/tags/pg_stat_checkpointer/</link><description>Recent content in Pg_stat_checkpointer on Postgres Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>PostgresScripts.com</copyright><lastBuildDate>Thu, 21 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.postgresscripts.com/tags/pg_stat_checkpointer/index.xml" rel="self" type="application/rss+xml"/><item><title>Tune PostgreSQL Background Writer with pg_stat_bgwriter</title><link>https://www.postgresscripts.com/post/tune-postgresql-background-writer-with-pg-stat-bgwriter/</link><pubDate>Thu, 21 May 2026 00:00:00 +0000</pubDate><guid>https://www.postgresscripts.com/post/tune-postgresql-background-writer-with-pg-stat-bgwriter/</guid><description>
&lt;h2 id="tune-postgresql-background-writer-with-pg_stat_bgwriter"&gt;Tune PostgreSQL Background Writer with pg_stat_bgwriter&lt;/h2&gt;
&lt;p&gt;Where &lt;code&gt;pg_stat_statements&lt;/code&gt; does query-level aggregation and &lt;code&gt;pgBadger&lt;/code&gt; does after-the-fact log analysis, &lt;code&gt;pg_stat_bgwriter&lt;/code&gt; operates at the buffer-cache layer — answering whether the bgwriter and checkpointer are keeping &lt;code&gt;shared_buffers&lt;/code&gt; clean enough that foreground queries never have to pay for a write inline. On a healthy OLTP cluster the answer is almost always yes; on a struggling one the counters say which knob to turn first.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="7945792173"
data-ad-format="auto"
data-full-width-responsive="true"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;When a PostgreSQL backend needs a clean buffer in &lt;code&gt;shared_buffers&lt;/code&gt; and none is available, something has to flush a dirty page back to disk before the backend can continue. Three subsystems share that workload. The &lt;strong&gt;checkpointer&lt;/strong&gt; flushes every dirty buffer at checkpoint time, spreading the writes over &lt;code&gt;checkpoint_completion_target × checkpoint_timeout&lt;/code&gt; to avoid I/O spikes. The &lt;strong&gt;background writer&lt;/strong&gt; (&amp;quot;bgwriter&amp;quot;) runs continuously, sweeping a small window of the LRU list each &lt;code&gt;bgwriter_delay&lt;/code&gt; and writing out dirty buffers to keep a runway of clean buffers available. And when neither of those has kept up, the &lt;strong&gt;user-facing backend&lt;/strong&gt; writes the buffer itself — inline, on the critical path of the query.&lt;/p&gt;</description></item></channel></rss>