Home Explore Blog CI



postgresql

37th chunk of `doc/src/sgml/config.sgml`
00ce114b5b009558c28225441d7ae6284ccb0ca99d29b5370000000100000fa0
 because while a repeatedly-dirtied page might
      otherwise be written only once per checkpoint interval, the
      background writer might write it several times as it is dirtied
      in the same interval.  The parameters discussed in this subsection
      can be used to tune the behavior for local needs.
     </para>

     <variablelist>
      <varlistentry id="guc-bgwriter-delay" xreflabel="bgwriter_delay">
       <term><varname>bgwriter_delay</varname> (<type>integer</type>)
       <indexterm>
        <primary><varname>bgwriter_delay</varname> configuration parameter</primary>
       </indexterm>
       </term>
       <listitem>
        <para>
         Specifies the delay between activity rounds for the
         background writer.  In each round the writer issues writes
         for some number of dirty buffers (controllable by the
         following parameters).  It then sleeps for
         the length of <varname>bgwriter_delay</varname>, and repeats.
         When there are no dirty buffers in the
         buffer pool, though, it goes into a longer sleep regardless of
         <varname>bgwriter_delay</varname>.
         If this value is specified without units, it is taken as milliseconds.
         The default value is 200
         milliseconds (<literal>200ms</literal>). Note that on some systems, the
         effective resolution of sleep delays is 10 milliseconds; setting
         <varname>bgwriter_delay</varname> to a value that is not a multiple of 10
         might have the same results as setting it to the next higher multiple
         of 10.  This parameter can only be set in the
         <filename>postgresql.conf</filename> file or on the server command line.
        </para>
       </listitem>
      </varlistentry>

      <varlistentry id="guc-bgwriter-lru-maxpages" xreflabel="bgwriter_lru_maxpages">
       <term><varname>bgwriter_lru_maxpages</varname> (<type>integer</type>)
       <indexterm>
        <primary><varname>bgwriter_lru_maxpages</varname> configuration parameter</primary>
       </indexterm>
       </term>
       <listitem>
        <para>
         In each round, no more than this many buffers will be written
         by the background writer.  Setting this to zero disables
         background writing.  (Note that checkpoints, which are managed by
         a separate, dedicated auxiliary process, are unaffected.)
         The default value is 100 buffers.
         This parameter can only be set in the <filename>postgresql.conf</filename>
         file or on the server command line.
        </para>
       </listitem>
      </varlistentry>

      <varlistentry id="guc-bgwriter-lru-multiplier" xreflabel="bgwriter_lru_multiplier">
       <term><varname>bgwriter_lru_multiplier</varname> (<type>floating point</type>)
       <indexterm>
        <primary><varname>bgwriter_lru_multiplier</varname> configuration parameter</primary>
       </indexterm>
       </term>
       <listitem>
        <para>
         The number of dirty buffers written in each round is based on the
         number of new buffers that have been needed by server processes
         during recent rounds.  The average recent need is multiplied by
         <varname>bgwriter_lru_multiplier</varname> to arrive at an estimate of the
         number of buffers that will be needed during the next round.  Dirty
         buffers are written until there are that many clean, reusable buffers
         available.  (However, no more than <varname>bgwriter_lru_maxpages</varname>
         buffers will be written per round.)
         Thus, a setting of 1.0 represents a <quote>just in time</quote> policy
         of writing exactly the number of buffers predicted to be needed.
         Larger values provide some cushion against spikes in demand,
         while smaller values intentionally leave writes to be done by
         server processes.
         The default is 2.0.
         This parameter can only be set in the <filename>postgresql.conf</filename>
 

Title: Background Writer Configuration: bgwriter_delay, bgwriter_lru_maxpages, and bgwriter_lru_multiplier
Summary
This section details configuration parameters for the background writer process. `bgwriter_delay` sets the delay between activity rounds (default 200ms). `bgwriter_lru_maxpages` limits the number of buffers written per round; setting it to zero disables background writing (default 100). `bgwriter_lru_multiplier` determines the number of dirty buffers written based on recent buffer needs, aiming for a 'just in time' or cushioned writing policy (default 2.0). All these parameters can only be set in postgresql.conf or on the server command line.