A function returning the current WAL flush location

pg_current_wal_flush_lsn() is a system function returning the current write-ahead log flush location.

pg_current_wal_flush_lsn() was added in PostgreSQL 9.6 (as pg_current_xlog_flush_location()).


pg_current_wal_flush_lsn () → pg_lsn

The flush location is the last WAL location known to be written to durable storage.

pg_current_wal_flush_lsn() cannot be executed if PostgreSQL is in recovery (i.e. on a standby).

Change history


Sample output from pg_current_wal_flush_lsn():

postgres=# SELECT pg_current_wal_flush_lsn(), pg_current_wal_lsn(), pg_current_wal_insert_lsn();
 pg_current_wal_flush_lsn | pg_current_wal_lsn | pg_current_wal_insert_lsn 
 4/2F000000               | 4/2F4C6000         | 4/2F8C4E78
(1 row)

Executing on a standby:

postgres=# SELECT pg_current_wal_flush_lsn();
ERROR:  recovery is in progress
HINT:  WAL control functions cannot be executed during recovery.


System function, WAL

See also

pg_current_wal_lsn(), pg_current_wal_insert_lsn()