pg_last_wal_receive_lsn()

A function returning the most recent WAL location received by a standby

pg_last_wal_receive_lsn() is a system function returning the most recent WAL location that has been received and synced to disk by a streaming replication standby.

pg_last_wal_receive_lsn() was added in PostgreSQL 9.0 as pg_last_xlog_receive_location().

Usage

pg_last_wal_receive_lsn() → pg_lsn

Change history

Examples

Basic usage example for pg_last_wal_receive_lsn():

postgres=# SELECT pg_last_wal_receive_lsn();
 pg_last_wal_receive_lsn 
-------------------------
 7/9E1F09B8
(1 row)

This value is also reported via the sent_lsn column in the upstream node's pg_stat_replication entry for the standby:

postgres=# SELECT sent_lsn FROM pg_stat_replication WHERE application_name='node2';
 replay_lsn 
------------
 7/9E1F09B8
(1 row)

Categories

Replication, System function, WAL

See also

pg_last_wal_replay_lsn()