AI IntelligenceNov 19, 2026Practical Tip
Article
PostgreSQL 19 adds a WAIT FOR LSN command so a session on a standby can wait until the standby has replayed the WAL up to a…
…specific log sequence number before running a query, giving "read-your-writes" consistency for applications that send reads to standbys.
AI-generated: summaries written by AI from the linked sources. How we use AI
AI-generatedSource: Simon Willison
01
Source Brief
PostgreSQL 19 adds a WAIT FOR LSN command so a session on a standby can wait until the standby has replayed the WAL up to a specific log sequence number before running a query, giving "read-your-writes" consistency for applications that send reads to standbys.
02
Practical Tip
After writing on the primary, capture the LSN with SELECT pg_current_wal_insert_lsn(); store it (the author suggests a signed cookie would work), then on a later request run WAIT FOR LSN '0/0306EE20' WITH (TIMEOUT '0.1s'); before the read. The timeout is optional; with one, you get an error if the replica doesn't catch up.
03