Subject: Re: Reconcile stats in find_tabstat_entry() and get rid of PgStat_BackendFunctionEntry

From: "Drouvot, Bertrand" <[email-masked]>
Date: Wed, 29 Mar 2023 07:44:20 +0200

Hi,

On 3/29/23 2:09 AM, Michael Paquier wrote:
> On Tue, Mar 28, 2023 at 05:43:26PM +0900, Kyotaro Horiguchi wrote:
>> No. Fine by me, except that "block read requests" seems to suggest
>> kernel read() calls, maybe because it's not clear whether "block"
>> refers to our buffer blocks or file blocks to me.. If it is generally
>> clear, I'm fine with the proposal.
> 
> Okay.  Would somebody like to draft a patch?

Please find a draft attached.

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index c809ff1ba4..ae5d9a0226 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -5724,8 +5724,10 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
         <returnvalue>bigint</returnvalue>
        </para>
        <para>
-        Returns the number of buffers fetched for table or index, in the current
-        transaction.
+        Returns the number of block read requests for table or index, in the
+        current transaction. This number minus <function>
+        pg_stat_get_xact_blocks_hit</function> gives the number of kernel
+        <function>read()</function> calls.
        </para></entry>
       </row>
 
@@ -5738,8 +5740,9 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
         <returnvalue>bigint</returnvalue>
        </para>
        <para>
-        Returns the number of buffer hits for table or index, in the current
-        transaction.
+        Returns the number of block read requests for table or index, in the
+        current transaction, found in cache (not triggering kernel
+        <function>read()</function> calls).
        </para></entry>
       </row>

---

From: Michael Paquier <[email-masked]>
Date: Tue, 4 Apr 2023 21:04:34 +0900

> Please find a draft attached.

This addition looks OK for me.  Thanks for the patch!
--
Michael

---

From: Michael Paquier <[email-masked]>
Date: Wed, 5 Apr 2023 08:05:27 +0900

> This addition looks OK for me.  Thanks for the patch!

Okay, finally done.  One part that was still not complete to me in
light of the information ddfc2d9 has removed is that the number of
physical reads could be lower than the reported number depending on
what the kernel cache holds.  So I've added this sentence, while on
it.
--
Michael