PostgreSQL 19 helps apps show the edit you just saved
A read replica can serve yesterday’s display name a moment after you change it. A new command lets an app wait for that particular save before it reloads the profile.
You change your display name, tap Save and find the old name staring back from your profile. Refresh once and the new one appears. An app can behave like this even when the database saved the edit correctly. One server accepted the change. A second server answered the next request before it had applied it. PostgreSQL 19, released on November 19, gives the app a way to ask that second server a precise question before it shows you the profile. Have you reached the point where my edit was committed?
The new command is WAIT FOR LSN. Its value lies in where the wait happens. A public profile may get thousands of visits between edits. Most visitors can tolerate seeing a slightly older name. The person who just pressed Save has a good reason to expect the new one on the very next screen.
How the read catches up with the save
In a common PostgreSQL setup, a primary server handles writes and a standby can answer reads. The primary records changes in its write-ahead log, or WAL. A standby receives that log and replays it to bring its own copy forward. While replication is asynchronous, the primary can acknowledge a save while the standby still has work to do. This is a different delay from the time it takes to distribute a DNS change. Here the application can identify a position in the database’s own history.
A log position is more useful here than a timer. An app that always sleeps for half a second makes the reader wait even when the replica is already current. If the replica is two seconds behind, the same half-second pause still leaves room for the old name to appear. The PostgreSQL standby guide shows how to tie the read to completed work instead. A standby that has passed the requested point can return immediately.
What a successful wait actually promises
A replica can receive the information for an edit and write it to disk before it applies that edit to the tables a query sees. PostgreSQL offers distinct wait modes for those stages. For the profile screen, replay is the relevant one. The command reference also specifies the order of operations. Wait before starting the work that takes locks or establishes an older view of the data. Waiting on one replica and then sending the query to a different one loses the connection between the check and the answer.
Reaching the target establishes a minimum. If a colleague edits the same shared profile again, a fresh query may show that later name. The point is to avoid slipping back to a version that predates the save. As the transaction isolation guide explains, what else a query sees depends on when it takes its snapshot.
The interesting decision comes when the replica is slow. An application can set a timeout and, if it expires, route this particular read to the primary. That costs the primary a query. Showing an explicit pending state buys time instead. Returning the old name as if the save had failed risks prompting the user to submit it twice. PostgreSQL 19 leaves that choice with the application, but the profile screen finally has something better to go on than the speed of its refresh button.