---
title: "More load is faster: Tuning Postgres read replicas"
description: "A ClickHouse Managed Postgres user reported unexpectedly high read replica delay, prompting an investigation into Postgres replication lag tuning. The author found that with default settings, replica lag follows a U-shaped curve: low and high throughput cause large spikes, while moderate load yields only a few seconds of delay. Tuning archive_timeout to 5s and wal_retrieve_retry_interval to 500ms provides a safe starting point for reducing lag. More aggressive tuning, such as forcing WAL switches with pg_switch_wal() or using a WAL-G daemon client, can further reduce lag but introduces tradeoffs like increased network costs and CPU overhead. Streaming replication still achieves lower lag than archive-based replication, but the author notes that a few seconds of lag is sufficient for most use cases."
---

# More load is faster: Tuning Postgres read replicas

[Clickhouse](https://yomu.fyi/company/clickhouse) · Colton Shepard · Nov 17, 2026

**Type:** Explainer

## Summary

A ClickHouse Managed Postgres user reported unexpectedly high read replica delay, prompting an investigation into Postgres replication lag tuning. The author found that with default settings, replica lag follows a U-shaped curve: low and high throughput cause large spikes, while moderate load yields only a few seconds of delay. Tuning archive\_timeout to 5s and wal\_retrieve\_retry\_interval to 500ms provides a safe starting point for reducing lag. More aggressive tuning, such as forcing WAL switches with pg\_switch\_wal() or using a WAL-G daemon client, can further reduce lag but introduces tradeoffs like increased network costs and CPU overhead. Streaming replication still achieves lower lag than archive-based replication, but the author notes that a few seconds of lag is sufficient for most use cases.

## Context

A user reported unexpectedly high read replica delay on ClickHouse Managed Postgres, prompting investigation into Postgres configuration options for replication lag. The author found that conventional wisdom about tuning was outdated and that low write traffic causes long delays due to the 60-second WAL segment switch timeout.

## Approach / What changed

The author tested Postgres read replica lag by running pgbench on ClickHouse Managed Postgres instances (i8g.large, 16GB RAM, 2 vCPUs, PG 18.6) with a heartbeat tool writing every 200ms. They tuned archive\_timeout and wal\_retrieve\_retry\_interval, and experimented with pg\_switch\_wal() and a WAL-G daemon client to reduce fetch overhead.

## Takeaways

- Replica lag with default Postgres tuning is U-shaped: very low and very high write throughput both cause large spikes, while moderate load (e.g., 12MB/s WAL) yields ~3 seconds of delay.
- Setting archive\_timeout=5s and wal\_retrieve\_retry\_interval=500ms is a safe starting point for reducing replica lag without major tradeoffs.
- Forcing WAL switches with pg\_switch\_wal() at sub-second intervals can reduce lag but increases network overhead and primary CPU load by ~15%.

## FAQ

### How does archive\_timeout affect replica lag?

archive\_timeout controls how long Postgres waits before shipping a WAL segment even if it isn't full. Lowering it (e.g., to 5s) forces more frequent shipping, reducing replica lag at low write throughput. However, it increases network overhead, especially with synchronous HA standbys.

### Can WAL segment size be tuned after database creation?

Yes, but it requires a maintenance window using initdb --wal-segsize or pg\_resetwal --wal-segsize. It is not practical for tuning an existing production environment.

### What tradeoff does the WAL-G daemon client introduce?

Using a WAL-G daemon client shaved about 55ms on a hit and 85ms on a miss per fetch, significantly reducing overhead for very short switch intervals (e.g., 250ms). However, it adds external dependencies to the replay path, which is risky for production.

**Tags:** [ClickHouse](https://yomu.fyi/topic/clickhouse), [Performance](https://yomu.fyi/topic/performance), [Postgres](https://yomu.fyi/topic/postgres), [Replication](https://yomu.fyi/topic/replication)

- Source: [Clickhouse](https://clickhouse.com/blog/tuning-postgres-read-replicas)
- Source URL: https://clickhouse.com/blog/tuning-postgres-read-replicas
- Ingested by Yomu: 2026-11-18T12:00:14.065Z

[Read original post](https://clickhouse.com/blog/tuning-postgres-read-replicas)
