Updated on 2024-09-02 GMT+08:00

Checkpoints

checkpoint_segments

Parameter description: minimum number of WAL segment files in the period specified by checkpoint_timeout. The size of each log file is 16 MB.

Type: SIGHUP

Value range: an integer. The minimum value is 1.

Default value: 64

Increasing the value of this parameter speeds up the export of big data. Set this parameter based on checkpoint_timeout and shared_buffers. This parameter affects the number of WAL log segment files that can be reused. Generally, the maximum number of reused files in the pg_xlog folder is twice the number of checkpoint segments. The reused files are not deleted and are renamed to the WAL log segment files which will be later used.

checkpoint_timeout

Parameter description: Specifies the maximum time between automatic WAL checkpoints.

Type: SIGHUP

Value range: an integer ranging from 30 to 3600 (s)

Default value: 15min

If the value of checkpoint_segments is increased, you need to increase the value of this parameter. The increase of them further requires the increase of shared_buffers. Consider all these parameters during setting.

enable_delayed_unlinks

Parameter description: Specifies whether to enable delayed checkpoint deletion. This parameter is supported only by clusters of version 9.1.0 or later.

Type: SIGHUP

Value range: Boolean

  • on indicates that delayed checkpoint deletion is enabled.
  • off indicates that delayed checkpoint deletion is disabled.

Default value: on

  • When delayed checkpoint deletion is enabled, the primary DN will move the relfilenode file to be deleted to the pg_delayed_unlinks_bin directory of the corresponding database when creating a checkpoint.
  • To determine whether an OID is reused, the system not only checks whether the relfilenode file exists in the corresponding database directory, but also checks whether the pg_delayed_unlinks_bin directory exists.
  • After the standby DN replays to the corresponding checkpoint record, the primary DN will delete the batch of relfilenode files in the pg_delayed_unlinks_bin directory corresponding to the checkpoint replayed by the standby DN in the next checkpoint.
  • When there are enough delayed-deletion relfilenode records (10 million), the excess relfilenode files will remain in the pg_delayed_unlinks_bin directory until the corresponding database/tablespace is deleted or the node is restarted and the files are cleaned up.