pg_wal_lsn_diff()

A system function to calculate the difference between two WAL locations

pg_wal_lsn_diff() is a system function to calculate the difference between two WAL locations.

pg_wal_lsn_diff() was added in PostgreSQL 9.2 as pg_xlog_location_diff().

Usage

pg_wal_lsn_diff ( lsn1 pg_lsn, lsn2 pg_lsn ) → numeric

Change history

Examples

Basic usage of :

postgres=# SELECT pg_wal_lsn_diff('7/A25801C8', '7/A2000000');
 pg_wal_lsn_diff 
-----------------
         5767624
(1 row)

Note that from PostgreSQL 9.4, the same result can be achieved by casting both values to the pg_lsn data type and subtracting directly:

postgres=# SELECT '7/A25801C8'::pg_lsn - '7/A2000000'::pg_lsn;
 ?column? 
----------
  5767624
(1 row)

Categories

Replication, System function, WAL