Re: CHECKPOINT unlogged data
Re: CHECKPOINT unlogged data
От:
Laurenz Albe <laurenz.albe@cybertec.at>
Дата:
On Wed, 2025-06-11 at 17:53 +0200, Christoph Berg wrote:
> I haven't implemented a WAIT option yet since I didn't want to decide
> that without more votes in either direction.
I had a look at it, and I have suggestions for the documentation.
> --- a/doc/src/sgml/ref/checkpoint.sgml
> +++ b/doc/src/sgml/ref/checkpoint.sgml
> [...]
>
> - The CHECKPOINT 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
> - ).
> - CHECKPOINT is not intended for use during normal
> - operation.
> + Running CHECKPOINT is not required during normal
> + operation; the system schedules checkpoints automatically (controlled by
> + the settings in ).
> + CHECKPOINT can be beneficial to run before operations
> + such as binary backups or shutting down PostgreSQL
> + as this can reduce the amount of data to be flushed for the next checkpoint
> + within these operations. Specifically, UNLOGGED table
> + data is otherwise only flushed by the shutdown checkpoint.
>
How about the following for added clarity:
Running an explicit CHECKPOINT is not required during
normal operation; the system schedules checkpoints automatically (controlled
by the settings in ).
However, it can be useful to perform an explicit checkpoint immediately
before shutting down the server or performing an online file system backup,
if you want the checkpoint implicit in these operations to be as fast as
possible. In particular, UNLOGGED table data only get
flushed to disk during a shutdown checkpoint, so you should use the option
FLUSH_UNLOGGED for an explicit checkpoint right before a
shutdown.
>
> If executed during recovery, the CHECKPOINT command
> - will force a restartpoint (see )
> - rather than writing a new checkpoint.
> + will force a restartpoint rather than writing a new checkpoint. (The
> + operation will be a no-op if there is no corresponding checkpoint in the
> + write-ahead log.) If a checkpoint is already being written when a
> + CHECKPOINT is issued, the running checkpoint is upgraded
> + with this command's MODE and
> + FLUSH_UNLOGGED options.
>
Oh, interesting; I wasn't aware of that. That means that running CHECKPOINT
(FLUSH_UNLOGGED) is less useful than I thought, since there is often already
a spread checkpoint running. Would it be useful to recommend that you should
run the command twice when aiming for a fast shutdown?
@@ -58,6 +69,54 @@ CHECKPOINT
+
+ Parameters
+
+
+
+ MODE
+
+
+ The CHECKPOINT command forces a fast checkpoint by
+ default when the command is issued, without waiting for a regular
+ checkpoint scheduled by the system.
+
+
+ A SPREAD checkpoint will instead spread out the write
+ load as determined by the
+ setting, like the
+ system-scheduled checkpoints.
+
+
+
I find this somewhat confusing; how about
The default FAST mode causes the checkpoint to be
performed as fast as possible. A SPREAD checkpoint
will instead spread out the write load as determined by the
setting, like the
system-scheduled checkpoints.
+
+ FLUSH_UNLOGGED
+
+
+ All data files except for those marked as UNLOGGED
+ are flushed to disk during a checkpoint. Enabling this option will also
+ flush UNLOGGED relations; the default is off.
+
+
+
How about:
FLUSH_UNLOGGED
Normally, data files marked as UNLOGGED are not
flushed to disk during a checkpoint. Enabling this option will also
flush UNLOGGED relations. This option is disabled
by default.
Yours,
Laurenz Albe