recovery_min_apply_delay
Read PG 18 manual ↗By default, a standby server restores WAL records from the sending server as soon as possible.
- Type
- integer
- Context
- sighup
- Measured default
- 0 ms
- Unit
- ms
- Metadata snapshot
- 18
Definition PG 18 manual
By default, a standby server restores WAL records from the sending server as soon as possible. It may be useful to have a time-delayed copy of the data, offering opportunities to correct data loss errors. This parameter allows you to delay recovery by a specified amount of time. For example, if you set this parameter to 5min, the standby will replay each transaction commit only when the system time on the standby is at least five minutes past the commit time reported by the primary. If this value is specified without units, it is taken as milliseconds. The default is zero, adding no delay.
It is possible that the replication delay between servers exceeds the value of this parameter, in which case no delay is added. Note that the delay is calculated between the WAL time stamp as written on primary and the current time on the standby. Delays in transfer because of network lag or cascading replication configurations may reduce the actual wait time significantly. If the system clocks on primary and standby are not synchronized, this may lead to recovery applying records earlier than expected; but that is not a major issue because useful settings of this parameter are much larger than typical time deviations between servers.
The delay occurs only on WAL records for transaction commits. Other records are replayed as quickly as possible, which is not a problem because MVCC visibility rules ensure their effects are not visible until the corresponding commit record is applied.
The delay occurs once the database in recovery has reached a consistent state, until the standby is promoted or triggered. After that the standby will end recovery without further waiting.
WAL records must be kept on the standby until they are ready to be applied. Therefore, longer delays will result in a greater accumulation of WAL files, increasing disk space requirements for the standby's pg_wal directory.
This parameter is intended for use with streaming replication deployments; however, if the parameter is specified it will be honored in all cases except crash recovery. hot_standby_feedback will be delayed by use of this feature which could lead to bloat on the primary; use both together with care.
Synchronous replication is affected by this setting when synchronous_commit is set to remote_apply; every COMMIT will need to wait to be applied.
This parameter can only be set in the postgresql.conf file or on the server command line.
Measured default history
| Version interval | Default |
|---|---|
| 12 – 19 | 0 ms |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
Sets the minimum delay for applying changes during recovery. A configuration reload applies a new value; existing work already in flight is not retroactively changed.
A standby delays replay of each transaction commit until the configured time has elapsed since the primary's commit timestamp. Network/cascade lag counts toward the delay, clocks matter, and synchronous_commit=remote_apply makes primary commits wait through the intentional delay.
Monitor and change recovery_min_apply_delay together with max_standby_archive_delay, max_standby_streaming_delay, hot_standby. Validate on the relevant server role and real workload, then use its sighup context to choose session change, reload, or restart; a historical boot default is not the current effective value.
Operational considerations
Changing it on the wrong primary, standby, sender, or subscriber role.
Watching only configured bytes/time instead of actual lag, slot position, and worker state.
Failing over to a node that lacks the old primary's capacity or prerequisites.
Using infinite waits or WAL retention to hide a failed consumer.
Workload guidance
OLAP: Read standbys and logical subscribers often see long queries or large transactions. Put explicit bounds on replay/apply and monitor lag, worker saturation, slot restart_lsn, and conflict cancellations.
OLTP: Size recovery_min_apply_delay from topology, failover roles, slot/subscription count, and reconnect headroom. Test worst-case primary latency, standby replay, and disk retention before production.
SMALL: Configure only replication capacity that is actually used. Even a small topology needs bounded timeouts and slot lifecycle; unlimited retention is not reliability.
Version history 4
- PG 18 → 19changed
- PG 14 → 15changed
- PG 13 → 14changed
- PG 11 → 12added
Related entries
Further reading
Definition snapshot: english-manuals:caa0fc7b0d42579cf85c11a265e… · English manual source