pg_wal_lsn_diff ( lsn1 pg_lsn, lsn2 pg_lsn ) → numericCalculates the difference in bytes (lsn1 - lsn2) between two write-ahead log locations. This can be used with pg_stat_replication or some of the functions shown in Table 9.97 to get the replication lag.