# recovery_prefetch

> recovery_prefetch prefetches referenced blocks during recovery. It is a sighup setting present in PG15–18; the latest recorded boot default is try.
---

> [!NOTE]
> **Fact — official short description:** “Prefetch referenced blocks during recovery.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `enum` | Upstream pg_settings type |
| Context | `sighup` | Takes effect after configuration reload |
| Unit | — | Raw unit |
| Range | — | Raw limits in the last observed version |
| Enum values | `off`, `on`, `try` | — for non-enum types |
| Category | Write-Ahead Log / Recovery | Upstream classification |
| Latest boot value | `try` | try |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG15 |
| Present in | PG15–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`1d257577e08d`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1d257577e08d3e598011d6850fd1025858de8c8c) — Optionally prefetch referenced data in recovery. |
| Commit date | 2021-04-08 |
| Discussion | [thread 1](https://postgr.es/m/CA%2BhUKGJ4VJN8ttxScUFM8dOKX0BrBiboo5uz1cq%3DAovOddfHpA%40mail.gmail.com) |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG15–19 Beta 3 | `try` | — | try |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

Prefetch referenced blocks during recovery. A configuration reload applies a new value; existing work already in flight is not retroactively changed.

During recovery, PostgreSQL can issue read-ahead advice for blocks identified by WAL before replay needs them. try enables it only when the operating system supports the required advice; wal_decode_buffer_size and maintenance_io_concurrency bound how far and how much it can prefetch.

Monitor and change recovery_prefetch together with wal_decode_buffer_size, maintenance_io_concurrency, effective_io_concurrency. 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.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Tune recovery_prefetch with recovery/standby catch-up benchmarks on production-like storage while observing replay I/O wait, cache behavior, and maintenance_io_concurrency. Keep the default without measured benefit. |
| OLAP | Large data with slow random reads may benefit more, but excess prefetch competes with query I/O and cache. Test crash recovery and a query-serving standby separately. |
| Small nodes | The default is usually sufficient. Do not spend scarce memory or I/O queue depth on a larger look-ahead window unless a recovery-time objective is demonstrably missed. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | Unmodified | — | — |
| OLAP | Unmodified | — | — |
| CRIT | Unmodified | — | — |
| TINY | Unmodified | — | — |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG15–19 Beta 3 unmodified; OLAP: PG15–19 Beta 3 unmodified; CRIT: PG15–19 Beta 3 unmodified; TINY: PG15–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

## Common pitfalls {#common-pitfalls}

- Assuming try always enables prefetch even when the operating system lacks the required read-ahead advice.
- Increasing look-ahead without considering wal_decode_buffer_size and maintenance_io_concurrency.
- Letting recovery prefetch compete with queries on a hot standby for cache and I/O queue depth.
- Benchmarking sequential recovery only, where block prefetch may provide little benefit.

## Related parameters {#related-parameters}

[`wal_decode_buffer_size`](/parameters/wal-decode-buffer-size/) · [`maintenance_io_concurrency`](/parameters/maintenance-io-concurrency/) · [`effective_io_concurrency`](/parameters/effective-io-concurrency/) · [`shared_buffers`](/parameters/shared-buffers/) · [`archive_cleanup_command`](/parameters/archive-cleanup-command/) · [`archive_command`](/parameters/archive-command/)

## References {#references}

- [PostgreSQL 19 Beta 3 — recovery_prefetch](https://www.postgresql.org/docs/19/runtime-config-wal.html#GUC-RECOVERY-PREFETCH)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
