Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8QuG-0004bD-7u for pgsql-docs@arkaria.postgresql.org; Sat, 06 Feb 2021 16:58:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l8QuF-00009g-5X for pgsql-docs@arkaria.postgresql.org; Sat, 06 Feb 2021 16:57:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8QuF-00009W-0A for pgsql-docs@lists.postgresql.org; Sat, 06 Feb 2021 16:57:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8QuC-0006V3-W0 for pgsql-docs@lists.postgresql.org; Sat, 06 Feb 2021 16:57:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 116GvuAW190700; Sat, 6 Feb 2021 11:57:56 -0500 From: Tom Lane To: Tatsuo Ishii cc: pgsql-docs@lists.postgresql.org Subject: Re: pg_wal_lsn_diff In-reply-to: <20210206.151125.960423226279810864.t-ishii@sraoss.co.jp> References: <20210206.151125.960423226279810864.t-ishii@sraoss.co.jp> Comments: In-reply-to Tatsuo Ishii message dated "Sat, 06 Feb 2021 15:11:25 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <190698.1612630676.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 06 Feb 2021 11:57:56 -0500 Message-ID: <190699.1612630676@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tatsuo Ishii writes: > According to the pg_wal_lsn_diff manual: > pg_wal_lsn_diff ( lsn pg_lsn, lsn pg_lsn ) =1B$B"*=1B(B 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. +1 for fixing that. Two notes though: first, your text doesn't agree with the prototype ("ls1" should be "lsn1"), and second, I think it would read better if you didn't split the phrase "difference in bytes". That is, - Calculates the difference in bytes between two write-ahead log + Calculates the difference in bytes (lsn1 - lsn2) between two writ= e-ahead log Also maybe you should use the lsn1 markup in the text. regards, tom lane