Contents
CHECKPOINT
CHECKPOINT
is an SQL command which forces PostgreSQL to carry out an immediate checkpoint
, after which the on-disk datafiles are guaranteed to be up-to-date as of the point the command was executed.
CHECKPOINT
was added in PostgreSQL 7.1.
Usage
In PostgreSQL 14 and earlier, CHECKPOINT
can only be executed by a superuser.
In PostgreSQL 15 and later, CHECKPOINT
can be executed by a superuser or a user who is member of the predefined role pg_checkpointer.
Following execution of the CHECKPOINT
command, the checkpoints_req
column in pg_stat_bgwriter
will be incremented.
Change history
- PostgreSQL 7.1
- added (commit f0e37a85)
Examples
Execution of the CHECKPOINT
command:
postgres=# CHECKPOINT; CHECKPOINT
Log file output during the checkpoint operation (assuming log_checkpoints
is set to on
):
[2021-03-29 12:28:06 UTC] LOG: 00000: checkpoint starting: immediate force wait [2021-03-29 12:28:06 UTC] LOG: 00000: checkpoint complete: wrote 33 buffers (0.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.001 s; sync files=0, longest=0.000 s, average=0.000 s; distance=132 kB, estimate=132 kB
The checkpoints_req
column in pg_stat_bgwriter
will be incremented after each execution of the CHECKPOINT
command:
postgres=# SELECT checkpoints_timed, checkpoints_req FROM pg_stat_bgwriter; checkpoints_timed | checkpoints_req -------------------+----------------- 0 | 0 (1 row) postgres=# CHECKPOINT; CHECKPOINT postgres=# SELECT checkpoints_timed, checkpoints_req FROM pg_stat_bgwriter; checkpoints_timed | checkpoints_req -------------------+----------------- 0 | 1 (1 row)
References
- PostgreSQL documentation: CHECKPOINT