Configuration parameter

archive_timeout — PostgreSQL configuration parameter

Category Write Ahead Log Change scope Sighup

The archive_command or archive_library is only invoked for completed WAL segments.

At a glance

Property Value
Parameter archive_timeout
Category Write Ahead Log
Default 0
Value type integer
Change scope Reload (postgresql.conf, SIGHUP)
Available in PostgreSQL 12, 13, 14, 15, 16, 17, 18, 19 (added in 12)

What it does

The archive_command or archive_library is only invoked for completed WAL segments. Hence, if your server generates little WAL traffic (or has slack periods where it does so), there could be a long delay between the completion of a transaction and its safe recording in archive storage. To limit how old unarchived data can be, you can set archive_timeout to force the server to switch to a new WAL segment file periodically. When this parameter is greater than zero, the server will switch to a new segment file whenever this amount of time has elapsed since the last segment file switch, and there has been any database activity, including a single checkpoint (checkpoints are skipped if there is no database activity). Note that archived files that are closed early due to a forced switch are still the same length as completely full files. Therefore, it is unwise to use a very short archive_timeout — it will bloat your archive storage. archive_timeout settings of a minute or so are usually reasonable. You should consider using streaming physical replication, instead of archiving, if you want data to be copied off the primary server more quickly than that. If this value is specified without units, it is taken as seconds. This parameter can only be set in the postgresql.conf file or on the server command line.

(Description quoted from the official PostgreSQL documentation.)

How to apply a change

Set it in postgresql.conf (or with ALTER SYSTEM) and reload with SELECT pg_reload_conf(); or pg_ctl reload — no restart needed.

Inspect the current value and source with SHOW archive_timeout; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'archive_timeout';.

Tuning guidance

Set it (e.g. 60-300s) to force a WAL switch so the archive never lags more than that interval on low-traffic systems; too small wastes space archiving mostly-empty segments. It bounds RPO for archive-based recovery.

Reference

PostgreSQL documentation — archive_timeout.

Keep going

Related & next steps

Was this helpful?

← All configuration parameters