Configuration parameter

recovery_prefetch — PostgreSQL configuration parameter

Category Write Ahead Log

Whether to try to prefetch blocks that are referenced in the WAL that are not yet in the buffer pool, during recovery.

At a glance

Property Value
Parameter recovery_prefetch
Category Write Ahead Log
Default try
Value type enum
Change scope Per-session (SET)
Available in PostgreSQL 15, 16, 17, 18, 19 (added in 15)

What it does

Whether to try to prefetch blocks that are referenced in the WAL that are not yet in the buffer pool, during recovery. Valid values are off, on and try (the default). The setting try enables prefetching only if the operating system provides support for issuing read-ahead advice.

Prefetching blocks that will soon be needed can reduce I/O wait times during recovery with some workloads. See also the wal_decode_buffer_size and maintenance_io_concurrency settings, which limit prefetching activity.

(Description quoted from the official PostgreSQL documentation.)

How to apply a change

Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.

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

Tuning guidance

Leave try so a standby prefetches referenced blocks during WAL replay where supported, improving replay throughput on I/O-bound recovery; set off only if it causes problems.

Reference

PostgreSQL documentation — recovery_prefetch.

Keep going

Related & next steps

Was this helpful?

← All configuration parameters