---
title: "Read your writes: WAIT FOR in PostgreSQL 19"
description: "PostgreSQL 19 adds a top-level `WAIT FOR LSN` command that blocks a session until a standby has written, flushed or replayed WAL up to a given LSN, giving read-your-writes consistency on asynchronous replicas without the per-commit cost of `synchronous_commit = remote_apply`."
url: "https://swe.quest/articles/read-your-writes-wait-for-in-postgresql-19-ead8d2a645bd23c3"
canonical: "https://clickhouse.com/blog/postgresql-19-wait-for-read-your-writes"
source: "ClickHouse"
published: "2026-08-25"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 6
tags: ["postgres","replication","consistency"]
---

# Read your writes: WAIT FOR in PostgreSQL 19

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2026-08-25, 6 min read, Deep dive. Original: [https://clickhouse.com/blog/postgresql-19-wait-for-read-your-writes](https://clickhouse.com/blog/postgresql-19-wait-for-read-your-writes)

## Summary

PostgreSQL 19 adds a top-level \`WAIT FOR LSN\` command that blocks a session until a standby has written, flushed or replayed WAL up to a given LSN, giving read-your-writes consistency on asynchronous replicas without the per-commit cost of \`synchronous\_commit = remote\_apply\`. The pattern is to capture \`pg\_current\_wal\_insert\_lsn()\` after a write on the primary, then run \`WAIT FOR\` on the standby before reading. Options include MODE (standby\_replay, standby\_flush, standby\_write, primary\_flush), TIMEOUT and NO\_THROW. It must run as a snapshot-free utility command outside functions and above READ COMMITTED, because a held snapshot can stall WAL replay and self-deadlock. The feature took about 10 years and three reverts to land. Timeline changes after promotion are not tracked, and connection poolers and proxies are natural places to inject it transparently.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [Consistency models](https://swe.quest/tags/consistency.md) (Distributed systems)

## Prerequisites

- PostgreSQL streaming replication ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- WAL and LSNs
- MVCC snapshots

## Keywords

PostgreSQL 19, WAIT FOR, LSN, WAL, synchronous\_commit, pg\_stat\_activity

## Related posts

- [Don't add a read replica until you've read this](https://swe.quest/articles/don-t-add-a-read-replica-until-you-ve-read-this-a990a2b0dc14e87b.md): incident.io · 2026-07-21 · Medium · 18 min read · PostgreSQL, Replication, Consistency models, Go, Scaling
  incident.io moved nearly all Postgres read traffic to a read replica and had to preserve read-after-write consistency without hand-routing each query.
- [PostgreSQL 19 on ClickHouse Managed Postgres, from day one](https://swe.quest/articles/postgresql-19-on-clickhouse-managed-postgres-from-day-one-f842fb2eaa8035d3.md): ClickHouse · 2026-11-24 · Medium · 12 min read · PostgreSQL, Replication, Deployment, Databases
  PostgreSQL 19 has been generally available on ClickHouse Managed Postgres since its November 2026 release day.
- [Patching the PostgreSQL JDBC Driver](https://swe.quest/articles/patching-the-postgresql-jdbc-driver-47e9400eaa77f0d2.md): Zalando Engineering · 2023-11-08 · Medium · 10 min read · PostgreSQL, Replication, Event-driven architecture, Java & JVM, Open source
  Postgres logical replication slots for clients watching low-traffic tables never advance, so the server retains all WAL generated by other tables until disk fills and the node goes read-only.
- [More load is faster: Tuning Postgres read replicas](https://swe.quest/articles/more-load-is-faster-tuning-postgres-read-replicas-edfe2bbdc0de0a5f.md): ClickHouse · 2026-11-17 · Hard · 9 min read · PostgreSQL, Replication, Performance engineering
  Postgres read replicas fed from archived WAL (rather than streaming replication) show a U-shaped lag curve: idle systems wait up to archive\_timeout (60s) for a 16MB segment to fill, while very high write rates make archive upload fall behind.
- [Everyone gets faster writes: We turned off FPW's in Neon](https://swe.quest/articles/everyone-gets-faster-writes-we-turned-off-fpw-s-in-neon-60d0cd25f29077e7.md): Neon · 2026-05-07 · Hard · 7 min read · PostgreSQL, Storage engines, Performance engineering, Distributed databases
  Neon disabled Postgres full-page writes fleet-wide because its stateless compute streams WAL to a Paxos safekeeper quorum and has no local disk pages that can tear.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
