According to the pg_wal_lsn_diff manual:
pg_wal_lsn_diff ( lsn pg_lsn, lsn pg_lsn ) → numeric
Calculates the difference in bytes between two write-ahead log
locations. This can be used with pg_stat_replication or some of
the functions shown in Table 9.87 to get the replication lag.
It's not clear whether its return value is (first arg - second arg) or
(second arg - first arg). The order matters because the return value
could have a sign (it actually does first arg - second arg). Attached
is a patch to fix the description.
Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index b7150510ab..2870692164 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -25102,11 +25102,11 @@ SELECT collation for ('foo' COLLATE "de_DE");
<indexterm>
<primary>pg_wal_lsn_diff</primary>
</indexterm>
- <function>pg_wal_lsn_diff</function> ( <parameter>lsn</parameter> <type>pg_lsn</type>,
<parameter>lsn</parameter><type>pg_lsn</type> )
+ <function>pg_wal_lsn_diff</function> ( <parameter>lsn1</parameter> <type>pg_lsn</type>,
<parameter>lsn2</parameter><type>pg_lsn</type> )
<returnvalue>numeric</returnvalue>
</para>
<para>
- Calculates the difference in bytes between two write-ahead log
+ Calculates the difference (ls1 - ls2) in bytes between two write-ahead log
locations. This can be used
with <structname>pg_stat_replication</structname> or some of the
functions shown in <xref linkend="functions-admin-backup-table"/> to