Re: CHECKPOINT unlogged data

Christoph Berg <myon@debian.org>

From: Christoph Berg <myon@debian.org>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>, Fujii Masao <masao.fujii@oss.nttdata.com>, Andres Freund <andres@anarazel.de>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-09T21:21:59Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add FLUSH_UNLOGGED option to CHECKPOINT command.

  2. Add MODE option to CHECKPOINT command.

  3. Add option list to CHECKPOINT command.

  4. Rename CHECKPOINT_FLUSH_ALL to CHECKPOINT_FLUSH_UNLOGGED.

  5. Rename CHECKPOINT_IMMEDIATE to CHECKPOINT_FAST.

Re: Nathan Bossart
> Here is what I have staged for commit, which I'm planning to do on Friday.

> diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml
> index 9659f76042c..9be752fc12b 100644
> --- a/doc/src/sgml/ref/pg_basebackup.sgml
> +++ b/doc/src/sgml/ref/pg_basebackup.sgml
> @@ -500,7 +500,7 @@ PostgreSQL documentation
>        <term><option>--checkpoint={fast|spread}</option></term>
>        <listitem>
>         <para>
> -        Sets checkpoint mode to fast (immediate) or spread (the default)
> +        Sets checkpoint mode to fast or spread (the default)
>          (see <xref linkend="backup-lowlevel-base-backup"/>).

This is somewhat hard to parse, perhaps combine the two ()() into one:

        Sets checkpoint mode to fast or spread (the default is spread,
        see <xref linkend="backup-lowlevel-base-backup"/>).

(patch 4)
>    <para>
> -   The <command>CHECKPOINT</command> command forces a fast
> +   When <literal>MODE</literal> is set to <literal>FAST</literal>, which is the
> +   default, the <command>CHECKPOINT</command> command forces a fast
>     checkpoint when the command is issued, without waiting for a
>     regular checkpoint scheduled by the system (controlled by the settings in
>     <xref linkend="runtime-config-wal-checkpoints"/>).

Explaining what the option does when explicitly setting the default is
confusing. We should explain the opposite case instead:

  The <command>CHECKPOINT</command> command issues a fast checkpoint
  by default where writes run at full speed. When literal>MODE</literal>
  is set to <literal>SPREAD</literal>, writes are instead limited
  by the settings in <xref linkend="runtime-config-wal-checkpoints"/>.

(patch 5)
>    <variablelist>
> +   <varlistentry>
> +    <term><literal>FLUSH_UNLOGGED</literal></term>
> +    <listitem>
> +     <para>
> +      Normally, <command>CHECKPOINT</command> does not flush data files for
> +      unlogged relations.  This option, which is disabled by default, enables
> +      flushing unlogged relations.

More precise:

      Normally, <command>CHECKPOINT</command> does not flush dirty buffers of
      unlogged relations.  This option, which is disabled by default, enables
      flushing unlogged relations to disk.

Christoph