Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 5fea23694c765462b86d6ddf74461eab > files > 677

postgresql9.6-docs-9.6.22-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Write Ahead Log</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.6.22 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Server Configuration"
HREF="runtime-config.html"><LINK
REL="PREVIOUS"
TITLE="Resource Consumption"
HREF="runtime-config-resource.html"><LINK
REL="NEXT"
TITLE="Replication"
HREF="runtime-config-replication.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2021-05-18T09:16:10"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="4"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.6.22 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="Resource Consumption"
HREF="runtime-config-resource.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="runtime-config.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 19. Server Configuration</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="Replication"
HREF="runtime-config-replication.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="RUNTIME-CONFIG-WAL"
>19.5. Write Ahead Log</A
></H1
><P
>    For additional information on tuning these settings,
    see <A
HREF="wal-configuration.html"
>Section 30.4</A
>.
   </P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="RUNTIME-CONFIG-WAL-SETTINGS"
>19.5.1. Settings</A
></H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><A
NAME="GUC-WAL-LEVEL"
></A
><TT
CLASS="VARNAME"
>wal_level</TT
> (<TT
CLASS="TYPE"
>enum</TT
>)
      </DT
><DD
><P
>        <TT
CLASS="VARNAME"
>wal_level</TT
> determines how much information is written
        to the WAL. The default value is <TT
CLASS="LITERAL"
>minimal</TT
>, which writes
        only the information needed to recover from a crash or immediate
        shutdown. <TT
CLASS="LITERAL"
>replica</TT
> adds logging required for WAL
        archiving as well as information required to run
        read-only queries on a standby server.  Finally,
        <TT
CLASS="LITERAL"
>logical</TT
> adds information necessary to support logical
        decoding.  Each level includes the information logged at all lower
        levels.  This parameter can only be set at server start.
       </P
><P
>        In <TT
CLASS="LITERAL"
>minimal</TT
> level, WAL-logging of some bulk
        operations can be safely skipped, which can make those
        operations much faster (see <A
HREF="populate.html#POPULATE-PITR"
>Section 14.4.7</A
>).
        Operations in which this optimization can be applied include:
        <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><TT
CLASS="COMMAND"
>CREATE TABLE AS</TT
></TD
></TR
><TR
><TD
><TT
CLASS="COMMAND"
>CREATE INDEX</TT
></TD
></TR
><TR
><TD
><TT
CLASS="COMMAND"
>CLUSTER</TT
></TD
></TR
><TR
><TD
><TT
CLASS="COMMAND"
>COPY</TT
> into tables that were created or truncated in the same
         transaction</TD
></TR
></TBODY
></TABLE
><P
></P
>
        But minimal WAL does not contain enough information to reconstruct the
        data from a base backup and the WAL logs, so <TT
CLASS="LITERAL"
>replica</TT
> or
        higher must be used to enable WAL archiving
        (<A
HREF="runtime-config-wal.html#GUC-ARCHIVE-MODE"
>archive_mode</A
>) and streaming replication.
       </P
><P
>        In <TT
CLASS="LITERAL"
>logical</TT
> level, the same information is logged as
        with <TT
CLASS="LITERAL"
>replica</TT
>, plus information needed to allow
        extracting logical change sets from the WAL. Using a level of
        <TT
CLASS="LITERAL"
>logical</TT
> will increase the WAL volume, particularly if many
        tables are configured for <TT
CLASS="LITERAL"
>REPLICA IDENTITY FULL</TT
> and
        many <TT
CLASS="COMMAND"
>UPDATE</TT
> and <TT
CLASS="COMMAND"
>DELETE</TT
> statements are
        executed.
       </P
><P
>        In releases prior to 9.6, this parameter also allowed the
        values <TT
CLASS="LITERAL"
>archive</TT
> and <TT
CLASS="LITERAL"
>hot_standby</TT
>.
        These are still accepted but mapped to <TT
CLASS="LITERAL"
>replica</TT
>.
       </P
></DD
><DT
><A
NAME="GUC-FSYNC"
></A
><TT
CLASS="VARNAME"
>fsync</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)
      </DT
><DD
><P
>        If this parameter is on, the <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> server
        will try to make sure that updates are physically written to
        disk, by issuing <CODE
CLASS="FUNCTION"
>fsync()</CODE
> system calls or various
        equivalent methods (see <A
HREF="runtime-config-wal.html#GUC-WAL-SYNC-METHOD"
>wal_sync_method</A
>).
        This ensures that the database cluster can recover to a
        consistent state after an operating system or hardware crash.
       </P
><P
>        While turning off <TT
CLASS="VARNAME"
>fsync</TT
> is often a performance
        benefit, this can result in unrecoverable data corruption in
        the event of a power failure or system crash.  Thus it
        is only advisable to turn off <TT
CLASS="VARNAME"
>fsync</TT
> if
        you can easily recreate your entire database from external
        data.
       </P
><P
>        Examples of safe circumstances for turning off
        <TT
CLASS="VARNAME"
>fsync</TT
> include the initial loading of a new
        database cluster from a backup file, using a database cluster
        for processing a batch of data after which the database
        will be thrown away and recreated,
        or for a read-only database clone which
        gets recreated frequently and is not used for failover.  High
        quality hardware alone is not a sufficient justification for
        turning off <TT
CLASS="VARNAME"
>fsync</TT
>.
       </P
><P
>        For reliable recovery when changing <TT
CLASS="VARNAME"
>fsync</TT
>
        off to on, it is necessary to force all modified buffers in the
        kernel to durable storage.  This can be done while the cluster
        is shutdown or while fsync is on by running <TT
CLASS="COMMAND"
>initdb
        --sync-only</TT
>, running <TT
CLASS="COMMAND"
>sync</TT
>, unmounting the
        file system, or rebooting the server.
       </P
><P
>        In many situations, turning off <A
HREF="runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT"
>synchronous_commit</A
>
        for noncritical transactions can provide much of the potential
        performance benefit of turning off <TT
CLASS="VARNAME"
>fsync</TT
>, without
        the attendant risks of data corruption.
       </P
><P
>        <TT
CLASS="VARNAME"
>fsync</TT
> can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
        If you turn this parameter off, also consider turning off
        <A
HREF="runtime-config-wal.html#GUC-FULL-PAGE-WRITES"
>full_page_writes</A
>.
       </P
></DD
><DT
><A
NAME="GUC-SYNCHRONOUS-COMMIT"
></A
><TT
CLASS="VARNAME"
>synchronous_commit</TT
> (<TT
CLASS="TYPE"
>enum</TT
>)
      </DT
><DD
><P
>        Specifies how much WAL processing must complete before
        the database server returns a <SPAN
CLASS="QUOTE"
>"success"</SPAN
>
        indication to the client.  Valid values are
        <TT
CLASS="LITERAL"
>remote_apply</TT
>, <TT
CLASS="LITERAL"
>on</TT
>
        (the default), <TT
CLASS="LITERAL"
>remote_write</TT
>,
        <TT
CLASS="LITERAL"
>local</TT
>, and <TT
CLASS="LITERAL"
>off</TT
>.
       </P
><P
>        If <TT
CLASS="VARNAME"
>synchronous_standby_names</TT
> is empty,
        the only meaningful settings are <TT
CLASS="LITERAL"
>on</TT
> and
        <TT
CLASS="LITERAL"
>off</TT
>;  <TT
CLASS="LITERAL"
>remote_apply</TT
>,
        <TT
CLASS="LITERAL"
>remote_write</TT
> and <TT
CLASS="LITERAL"
>local</TT
>
        all provide the same local synchronization level
        as <TT
CLASS="LITERAL"
>on</TT
>.  The local behavior of all
        non-<TT
CLASS="LITERAL"
>off</TT
> modes is to wait for local flush of WAL
        to disk.  In <TT
CLASS="LITERAL"
>off</TT
> mode, there is no waiting,
        so there can be a delay between when success is reported to the
        client and when the transaction is later guaranteed to be safe
        against a server crash.  (The maximum
        delay is three times <A
HREF="runtime-config-wal.html#GUC-WAL-WRITER-DELAY"
>wal_writer_delay</A
>.)  Unlike
        <A
HREF="runtime-config-wal.html#GUC-FSYNC"
>fsync</A
>, setting this parameter to <TT
CLASS="LITERAL"
>off</TT
>
        does not create any risk of database inconsistency: an operating
        system or database crash might
        result in some recent allegedly-committed transactions being lost, but
        the database state will be just the same as if those transactions had
        been aborted cleanly.  So, turning <TT
CLASS="VARNAME"
>synchronous_commit</TT
> off
        can be a useful alternative when performance is more important than
        exact certainty about the durability of a transaction.  For more
        discussion see <A
HREF="wal-async-commit.html"
>Section 30.3</A
>.
       </P
><P
>        If <A
HREF="runtime-config-replication.html#GUC-SYNCHRONOUS-STANDBY-NAMES"
>synchronous_standby_names</A
> is non-empty,
        <TT
CLASS="VARNAME"
>synchronous_commit</TT
> also controls whether
        transaction commits will wait for their WAL records to be
        processed on the standby server(s).
       </P
><P
>        When set to <TT
CLASS="LITERAL"
>remote_apply</TT
>, commits will wait
        until replies from the current synchronous standby(s) indicate they
        have received the commit record of the transaction and applied
        it, so that it has become visible to queries on the standby(s),
        and also written to durable storage on the standbys.  This will
        cause much larger commit delays than previous settings since
        it waits for WAL replay.  When set to <TT
CLASS="LITERAL"
>on</TT
>,
        commits wait until replies
        from the current synchronous standby(s) indicate they have received
        the commit record of the transaction and flushed it to durable storage.  This
        ensures the transaction will not be lost unless both the primary and
        all synchronous standbys suffer corruption of their database storage.
        When set to <TT
CLASS="LITERAL"
>remote_write</TT
>, commits will wait until replies
        from the current synchronous standby(s) indicate they have
        received the commit record of the transaction and written it to
        their file systems. This setting ensures data preservation if a standby instance of
        <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> crashes, but not if the standby
        suffers an operating-system-level crash because the data has not
        necessarily reached durable storage on the standby.
        The setting <TT
CLASS="LITERAL"
>local</TT
> causes commits to wait for
        local flush to disk, but not for replication.  This is usually not
        desirable when synchronous replication is in use, but is provided for
        completeness.
       </P
><P
>        This parameter can be changed at any time; the behavior for any
        one transaction is determined by the setting in effect when it
        commits.  It is therefore possible, and useful, to have some
        transactions commit synchronously and others asynchronously.
        For example, to make a single multistatement transaction commit
        asynchronously when the default is the opposite, issue <TT
CLASS="COMMAND"
>SET
        LOCAL synchronous_commit TO OFF</TT
> within the transaction.
       </P
><P
>        <A
HREF="runtime-config-wal.html#SYNCHRONOUS-COMMIT-MATRIX"
>Table 19-1</A
> summarizes the
        capabilities of the <TT
CLASS="VARNAME"
>synchronous_commit</TT
> settings.
       </P
><DIV
CLASS="TABLE"
><A
NAME="SYNCHRONOUS-COMMIT-MATRIX"
></A
><P
><B
>Table 19-1. synchronous_commit Modes</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL
WIDTH="1*"
TITLE="col1"><COL
WIDTH="1*"
TITLE="col2"><COL
WIDTH="1*"
TITLE="col3"><COL
WIDTH="1*"
TITLE="col4"><COL
WIDTH="1*"
TITLE="col5"><THEAD
><TR
><TH
>synchronous_commit setting</TH
><TH
>local durable commit</TH
><TH
>standby durable commit after PG crash</TH
><TH
>standby durable commit after OS crash</TH
><TH
>standby query consistency</TH
></TR
></THEAD
><TBODY
><TR
><TD
>remote_apply</TD
><TD
ALIGN="CENTER"
>&bull;</TD
><TD
ALIGN="CENTER"
>&bull;</TD
><TD
ALIGN="CENTER"
>&bull;</TD
><TD
ALIGN="CENTER"
>&bull;</TD
></TR
><TR
><TD
>on</TD
><TD
ALIGN="CENTER"
>&bull;</TD
><TD
ALIGN="CENTER"
>&bull;</TD
><TD
ALIGN="CENTER"
>&bull;</TD
><TD
ALIGN="CENTER"
>&nbsp;</TD
></TR
><TR
><TD
>remote_write</TD
><TD
ALIGN="CENTER"
>&bull;</TD
><TD
ALIGN="CENTER"
>&bull;</TD
><TD
ALIGN="CENTER"
>&nbsp;</TD
><TD
ALIGN="CENTER"
>&nbsp;</TD
></TR
><TR
><TD
>local</TD
><TD
ALIGN="CENTER"
>&bull;</TD
><TD
ALIGN="CENTER"
>&nbsp;</TD
><TD
ALIGN="CENTER"
>&nbsp;</TD
><TD
ALIGN="CENTER"
>&nbsp;</TD
></TR
><TR
><TD
>off</TD
><TD
ALIGN="CENTER"
>&nbsp;</TD
><TD
ALIGN="CENTER"
>&nbsp;</TD
><TD
ALIGN="CENTER"
>&nbsp;</TD
><TD
ALIGN="CENTER"
>&nbsp;</TD
></TR
></TBODY
></TABLE
></DIV
></DD
><DT
><A
NAME="GUC-WAL-SYNC-METHOD"
></A
><TT
CLASS="VARNAME"
>wal_sync_method</TT
> (<TT
CLASS="TYPE"
>enum</TT
>)
      </DT
><DD
><P
>        Method used for forcing WAL updates out to disk.
        If <TT
CLASS="VARNAME"
>fsync</TT
> is off then this setting is irrelevant,
        since WAL file updates will not be forced out at all.
        Possible values are:
       </P
><P
></P
><UL
><LI
><P
>         <TT
CLASS="LITERAL"
>open_datasync</TT
> (write WAL files with <CODE
CLASS="FUNCTION"
>open()</CODE
> option <TT
CLASS="SYMBOL"
>O_DSYNC</TT
>)
        </P
></LI
><LI
><P
>         <TT
CLASS="LITERAL"
>fdatasync</TT
> (call <CODE
CLASS="FUNCTION"
>fdatasync()</CODE
> at each commit)
        </P
></LI
><LI
><P
>         <TT
CLASS="LITERAL"
>fsync</TT
> (call <CODE
CLASS="FUNCTION"
>fsync()</CODE
> at each commit)
        </P
></LI
><LI
><P
>         <TT
CLASS="LITERAL"
>fsync_writethrough</TT
> (call <CODE
CLASS="FUNCTION"
>fsync()</CODE
> at each commit, forcing write-through of any disk write cache)
        </P
></LI
><LI
><P
>         <TT
CLASS="LITERAL"
>open_sync</TT
> (write WAL files with <CODE
CLASS="FUNCTION"
>open()</CODE
> option <TT
CLASS="SYMBOL"
>O_SYNC</TT
>)
        </P
></LI
></UL
><P
>        The <TT
CLASS="LITERAL"
>open_</TT
>* options also use <TT
CLASS="LITERAL"
>O_DIRECT</TT
> if available.
        Not all of these choices are available on all platforms.
        The default is the first method in the above list that is supported
        by the platform, except that <TT
CLASS="LITERAL"
>fdatasync</TT
> is the default on
        Linux and FreeBSD.  The default is not necessarily ideal; it might be
        necessary to change this setting or other aspects of your system
        configuration in order to create a crash-safe configuration or
        achieve optimal performance.
        These aspects are discussed in <A
HREF="wal-reliability.html"
>Section 30.1</A
>.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-FULL-PAGE-WRITES"
></A
><TT
CLASS="VARNAME"
>full_page_writes</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)
      </DT
><DD
><P
>        When this parameter is on, the <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> server
        writes the entire content of each disk page to WAL during the
        first modification of that page after a checkpoint.
        This is needed because
        a page write that is in process during an operating system crash might
        be only partially completed, leading to an on-disk page
        that contains a mix of old and new data.  The row-level change data
        normally stored in WAL will not be enough to completely restore
        such a page during post-crash recovery.  Storing the full page image
        guarantees that the page can be correctly restored, but at the price
        of increasing the amount of data that must be written to WAL.
        (Because WAL replay always starts from a checkpoint, it is sufficient
        to do this during the first change of each page after a checkpoint.
        Therefore, one way to reduce the cost of full-page writes is to
        increase the checkpoint interval parameters.)
       </P
><P
>        Turning this parameter off speeds normal operation, but
        might lead to either unrecoverable data corruption, or silent
        data corruption, after a system failure. The risks are similar to turning off
        <TT
CLASS="VARNAME"
>fsync</TT
>, though smaller, and it should be turned off
        only based on the same circumstances recommended for that parameter.
       </P
><P
>        Turning off this parameter does not affect use of
        WAL archiving for point-in-time recovery (PITR)
        (see <A
HREF="continuous-archiving.html"
>Section 25.3</A
>).
       </P
><P
>        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
        The default is <TT
CLASS="LITERAL"
>on</TT
>.
       </P
></DD
><DT
><A
NAME="GUC-WAL-LOG-HINTS"
></A
><TT
CLASS="VARNAME"
>wal_log_hints</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)
      </DT
><DD
><P
>        When this parameter is <TT
CLASS="LITERAL"
>on</TT
>, the <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>
        server writes the entire content of each disk page to WAL during the
        first modification of that page after a checkpoint, even for
        non-critical modifications of so-called hint bits.
       </P
><P
>        If data checksums are enabled, hint bit updates are always WAL-logged
        and this setting is ignored. You can use this setting to test how much
        extra WAL-logging would occur if your database had data checksums
        enabled.
       </P
><P
>        This parameter can only be set at server start. The default value is <TT
CLASS="LITERAL"
>off</TT
>.
       </P
></DD
><DT
><A
NAME="GUC-WAL-COMPRESSION"
></A
><TT
CLASS="VARNAME"
>wal_compression</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)
      </DT
><DD
><P
>        When this parameter is <TT
CLASS="LITERAL"
>on</TT
>, the <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>
        server compresses a full page image written to WAL when
        <A
HREF="runtime-config-wal.html#GUC-FULL-PAGE-WRITES"
>full_page_writes</A
> is on or during a base backup.
        A compressed page image will be decompressed during WAL replay.
        The default value is <TT
CLASS="LITERAL"
>off</TT
>.
        Only superusers can change this setting.
       </P
><P
>        Turning this parameter on can reduce the WAL volume without
        increasing the risk of unrecoverable data corruption,
        but at the cost of some extra CPU spent on the compression during
        WAL logging and on the decompression during WAL replay.
       </P
></DD
><DT
><A
NAME="GUC-WAL-BUFFERS"
></A
><TT
CLASS="VARNAME"
>wal_buffers</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        The amount of shared memory used for WAL data that has not yet been
        written to disk.  The default setting of -1 selects a size equal to
        1/32nd (about 3%) of <A
HREF="runtime-config-resource.html#GUC-SHARED-BUFFERS"
>shared_buffers</A
>, but not less
        than <TT
CLASS="LITERAL"
>64kB</TT
> nor more than the size of one WAL
        segment, typically <TT
CLASS="LITERAL"
>16MB</TT
>.  This value can be set
        manually if the automatic choice is too large or too small,
        but any positive value less than <TT
CLASS="LITERAL"
>32kB</TT
> will be
        treated as <TT
CLASS="LITERAL"
>32kB</TT
>.
        This parameter can only be set at server start.
       </P
><P
>        The contents of the WAL buffers are written out to disk at every
        transaction commit, so extremely large values are unlikely to
        provide a significant benefit.  However, setting this value to at
        least a few megabytes can improve write performance on a busy
        server where many clients are committing at once.  The auto-tuning
        selected by the default setting of -1 should give reasonable
        results in most cases.
       </P
></DD
><DT
><A
NAME="GUC-WAL-WRITER-DELAY"
></A
><TT
CLASS="VARNAME"
>wal_writer_delay</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        Specifies how often the WAL writer flushes WAL. After flushing WAL it
        sleeps for <TT
CLASS="VARNAME"
>wal_writer_delay</TT
> milliseconds, unless woken up
        by an asynchronously committing transaction. If the last flush
        happened less than <TT
CLASS="VARNAME"
>wal_writer_delay</TT
> milliseconds ago and
        less than <TT
CLASS="VARNAME"
>wal_writer_flush_after</TT
> bytes of WAL have been
        produced since, then WAL is only written to the operating system, not
        flushed to disk.
        The default value is 200 milliseconds (<TT
CLASS="LITERAL"
>200ms</TT
>).  Note that
        on many systems, the effective resolution of sleep delays is 10
        milliseconds; setting <TT
CLASS="VARNAME"
>wal_writer_delay</TT
> 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
        <TT
CLASS="FILENAME"
>postgresql.conf</TT
> file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-WAL-WRITER-FLUSH-AFTER"
></A
><TT
CLASS="VARNAME"
>wal_writer_flush_after</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        Specifies how often the WAL writer flushes WAL. If the last flush
        happened less than <TT
CLASS="VARNAME"
>wal_writer_delay</TT
> milliseconds ago and
        less than <TT
CLASS="VARNAME"
>wal_writer_flush_after</TT
> bytes of WAL have been
        produced since, then WAL is only written to the operating system, not
        flushed to disk.  If <TT
CLASS="VARNAME"
>wal_writer_flush_after</TT
> is set
        to <TT
CLASS="LITERAL"
>0</TT
> then WAL data is flushed immediately.  The default is
        <TT
CLASS="LITERAL"
>1MB</TT
>. This parameter can only be set in the
        <TT
CLASS="FILENAME"
>postgresql.conf</TT
> file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-COMMIT-DELAY"
></A
><TT
CLASS="VARNAME"
>commit_delay</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        <TT
CLASS="VARNAME"
>commit_delay</TT
> adds a time delay, measured in
        microseconds, before a WAL flush is initiated.  This can improve
        group commit throughput by allowing a larger number of transactions
        to commit via a single WAL flush, if system load is high enough
        that additional transactions become ready to commit within the
        given interval.  However, it also increases latency by up to
        <TT
CLASS="VARNAME"
>commit_delay</TT
> microseconds for each WAL
        flush.  Because the delay is just wasted if no other transactions
        become ready to commit, a delay is only performed if at least
        <TT
CLASS="VARNAME"
>commit_siblings</TT
> other transactions are active
        when a flush is about to be initiated.  Also, no delays are
        performed if <TT
CLASS="VARNAME"
>fsync</TT
> is disabled.
        The default <TT
CLASS="VARNAME"
>commit_delay</TT
> is zero (no delay).
        Only superusers can change this setting.
       </P
><P
>        In <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> releases prior to 9.3,
        <TT
CLASS="VARNAME"
>commit_delay</TT
> behaved differently and was much
        less effective: it affected only commits, rather than all WAL flushes,
        and waited for the entire configured delay even if the WAL flush
        was completed sooner.  Beginning in <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> 9.3,
        the first process that becomes ready to flush waits for the configured
        interval, while subsequent processes wait only until the leader
        completes the flush operation.
       </P
></DD
><DT
><A
NAME="GUC-COMMIT-SIBLINGS"
></A
><TT
CLASS="VARNAME"
>commit_siblings</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        Minimum number of concurrent open transactions to require
        before performing the <TT
CLASS="VARNAME"
>commit_delay</TT
> delay. A larger
        value makes it more probable that at least one other
        transaction will become ready to commit during the delay
        interval. The default is five transactions.
       </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="RUNTIME-CONFIG-WAL-CHECKPOINTS"
>19.5.2. Checkpoints</A
></H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><A
NAME="GUC-CHECKPOINT-TIMEOUT"
></A
><TT
CLASS="VARNAME"
>checkpoint_timeout</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        Maximum time between automatic WAL checkpoints, in seconds.
        The valid range is between 30 seconds and one day.
        The default is five minutes (<TT
CLASS="LITERAL"
>5min</TT
>).
        Increasing this parameter can increase the amount of time needed
        for crash recovery.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-CHECKPOINT-COMPLETION-TARGET"
></A
><TT
CLASS="VARNAME"
>checkpoint_completion_target</TT
> (<TT
CLASS="TYPE"
>floating point</TT
>)
      </DT
><DD
><P
>        Specifies the target of checkpoint completion, as a fraction of
        total time between checkpoints. The default is 0.5.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-CHECKPOINT-FLUSH-AFTER"
></A
><TT
CLASS="VARNAME"
>checkpoint_flush_after</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        Whenever more than <TT
CLASS="VARNAME"
>checkpoint_flush_after</TT
> bytes
        have been written while performing a checkpoint, attempt to force the
        OS to issue these writes to the underlying storage.  Doing so will
        limit the amount of dirty data in the kernel's page cache, reducing
        the likelihood of stalls when an fsync is issued at the end of the
        checkpoint, or when the OS writes data back in larger batches in the
        background.  Often that will result in greatly reduced transaction
        latency, but there also are some cases, especially with workloads
        that are bigger than <A
HREF="runtime-config-resource.html#GUC-SHARED-BUFFERS"
>shared_buffers</A
>, but smaller
        than the OS's page cache, where performance might degrade.  This
        setting may have no effect on some platforms.  The valid range is
        between <TT
CLASS="LITERAL"
>0</TT
>, which disables forced writeback,
        and <TT
CLASS="LITERAL"
>2MB</TT
>.  The default is <TT
CLASS="LITERAL"
>256kB</TT
> on
        Linux, <TT
CLASS="LITERAL"
>0</TT
> elsewhere.  (If <TT
CLASS="SYMBOL"
>BLCKSZ</TT
> is not
        8kB, the default and maximum values scale proportionally to it.)
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-CHECKPOINT-WARNING"
></A
><TT
CLASS="VARNAME"
>checkpoint_warning</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        Write a message to the server log if checkpoints caused by
        the filling of checkpoint segment files happen closer together
        than this many seconds (which suggests that
        <TT
CLASS="VARNAME"
>max_wal_size</TT
> ought to be raised).  The default is
        30 seconds (<TT
CLASS="LITERAL"
>30s</TT
>).  Zero disables the warning.
        No warnings will be generated if <TT
CLASS="VARNAME"
>checkpoint_timeout</TT
>
        is less than <TT
CLASS="VARNAME"
>checkpoint_warning</TT
>.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-MAX-WAL-SIZE"
></A
><TT
CLASS="VARNAME"
>max_wal_size</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        Maximum size to let the WAL grow during automatic
        checkpoints. This is a soft limit; WAL size can exceed
        <TT
CLASS="VARNAME"
>max_wal_size</TT
> under special circumstances, like
        under heavy load, a failing <TT
CLASS="VARNAME"
>archive_command</TT
>, or a high
        <TT
CLASS="VARNAME"
>wal_keep_segments</TT
> setting. The default is 1 GB.
        Increasing this parameter can increase the amount of time needed for
        crash recovery.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-MIN-WAL-SIZE"
></A
><TT
CLASS="VARNAME"
>min_wal_size</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        As long as WAL disk usage stays below this setting, old WAL files are
        always recycled for future use at a checkpoint, rather than removed.
        This can be used to ensure that enough WAL space is reserved to
        handle spikes in WAL usage, for example when running large batch
        jobs. The default is 80 MB.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="RUNTIME-CONFIG-WAL-ARCHIVING"
>19.5.3. Archiving</A
></H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><A
NAME="GUC-ARCHIVE-MODE"
></A
><TT
CLASS="VARNAME"
>archive_mode</TT
> (<TT
CLASS="TYPE"
>enum</TT
>)
      </DT
><DD
><P
>        When <TT
CLASS="VARNAME"
>archive_mode</TT
> is enabled, completed WAL segments
        are sent to archive storage by setting
        <A
HREF="runtime-config-wal.html#GUC-ARCHIVE-COMMAND"
>archive_command</A
>. In addition to <TT
CLASS="LITERAL"
>off</TT
>,
        to disable, there are two modes: <TT
CLASS="LITERAL"
>on</TT
>, and
        <TT
CLASS="LITERAL"
>always</TT
>. During normal operation, there is no
        difference between the two modes, but when set to <TT
CLASS="LITERAL"
>always</TT
>
        the WAL archiver is enabled also during archive recovery or standby
        mode. In <TT
CLASS="LITERAL"
>always</TT
> mode, all files restored from the archive
        or streamed with streaming replication will be archived (again). See
        <A
HREF="warm-standby.html#CONTINUOUS-ARCHIVING-IN-STANDBY"
>Section 26.2.9</A
> for details.
       </P
><P
>        <TT
CLASS="VARNAME"
>archive_mode</TT
> and <TT
CLASS="VARNAME"
>archive_command</TT
> are
        separate variables so that <TT
CLASS="VARNAME"
>archive_command</TT
> can be
        changed without leaving archiving mode.
        This parameter can only be set at server start.
        <TT
CLASS="VARNAME"
>archive_mode</TT
> cannot be enabled when
        <TT
CLASS="VARNAME"
>wal_level</TT
> is set to <TT
CLASS="LITERAL"
>minimal</TT
>.
       </P
></DD
><DT
><A
NAME="GUC-ARCHIVE-COMMAND"
></A
><TT
CLASS="VARNAME"
>archive_command</TT
> (<TT
CLASS="TYPE"
>string</TT
>)
      </DT
><DD
><P
>        The local shell command to execute to archive a completed WAL file
        segment.  Any <TT
CLASS="LITERAL"
>%p</TT
> in the string is
        replaced by the path name of the file to archive, and any
        <TT
CLASS="LITERAL"
>%f</TT
> is replaced by only the file name.
        (The path name is relative to the working directory of the server,
        i.e., the cluster's data directory.)
        Use <TT
CLASS="LITERAL"
>%%</TT
> to embed an actual <TT
CLASS="LITERAL"
>%</TT
> character in the
        command.  It is important for the command to return a zero
        exit status only if it succeeds. For more information see
        <A
HREF="continuous-archiving.html#BACKUP-ARCHIVING-WAL"
>Section 25.3.1</A
>.
       </P
><P
>        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.  It is ignored unless
        <TT
CLASS="VARNAME"
>archive_mode</TT
> was enabled at server start.
        If <TT
CLASS="VARNAME"
>archive_command</TT
> is an empty string (the default) while
        <TT
CLASS="VARNAME"
>archive_mode</TT
> is enabled, WAL archiving is temporarily
        disabled, but the server continues to accumulate WAL segment files in
        the expectation that a command will soon be provided.  Setting
        <TT
CLASS="VARNAME"
>archive_command</TT
> to a command that does nothing but
        return true, e.g., <TT
CLASS="LITERAL"
>/bin/true</TT
> (<TT
CLASS="LITERAL"
>REM</TT
> on
        Windows), effectively disables
        archiving, but also breaks the chain of WAL files needed for
        archive recovery, so it should only be used in unusual circumstances.
       </P
></DD
><DT
><A
NAME="GUC-ARCHIVE-TIMEOUT"
></A
><TT
CLASS="VARNAME"
>archive_timeout</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)
      </DT
><DD
><P
>        The <A
HREF="runtime-config-wal.html#GUC-ARCHIVE-COMMAND"
>archive_command</A
> is only invoked for
        completed WAL segments. Hence, if your server generates little WAL
        traffic (or has slack periods where it does so), there could be a
        long delay between the completion of a transaction and its safe
        recording in archive storage.  To limit how old unarchived
        data can be, you can set <TT
CLASS="VARNAME"
>archive_timeout</TT
> to force the
        server to switch to a new WAL segment file periodically.  When this
        parameter is greater than zero, the server will switch to a new
        segment file whenever this many seconds have elapsed since the last
        segment file switch, and there has been any database activity,
        including a single checkpoint.  (Increasing
        <TT
CLASS="VARNAME"
>checkpoint_timeout</TT
> will reduce unnecessary
        checkpoints on an idle system.)
        Note that archived files that are closed early
        due to a forced switch are still the same length as completely full
        files.  Therefore, it is unwise to use a very short
        <TT
CLASS="VARNAME"
>archive_timeout</TT
> &mdash; it will bloat your archive
        storage.  <TT
CLASS="VARNAME"
>archive_timeout</TT
> settings of a minute or so are
        usually reasonable.  You should consider using streaming replication,
        instead of archiving, if you want data to be copied off the master
        server more quickly than that.
        This parameter can only be set in the
        <TT
CLASS="FILENAME"
>postgresql.conf</TT
> file or on the server command line.
       </P
></DD
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="runtime-config-resource.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="runtime-config-replication.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Resource Consumption</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="runtime-config.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Replication</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>