Re: Summary function for pg_buffercache - Mailing list pgsql-hackers

From Zhang Mingli
Subject Re: Summary function for pg_buffercache
Date
Msg-id 21c5aab5-f265-4308-978d-e960c85c37f5@Spark
Whole thread Raw
In response to Re: Summary function for pg_buffercache  (Melih Mutlu <m.melihmutlu@gmail.com>)
Responses Re: Summary function for pg_buffercache
List pgsql-hackers

Regards,
Zhang Mingli
On Sep 28, 2022, 21:50 +0800, Melih Mutlu <m.melihmutlu@gmail.com>, wrote:
Hi all,

The patch needed a rebase due to recent changes on pg_buffercache.
You can find the updated version attached.

Best,
Melih


```
+
+ if (buffers_used != 0)
usagecount_avg = usagecount_avg / buffers_used;
+
+ memset(nulls, 0, sizeof(nulls));
+ values[0] = Int32GetDatum(buffers_used);
+ values[1] = Int32GetDatum(buffers_unused);
+ values[2] = Int32GetDatum(buffers_dirty);
+ values[3] = Int32GetDatum(buffers_pinned);
+
+ if (buffers_used != 0)
+ {
usagecount_avg = usagecount_avg / buffers_used;
+ values[4] = Float4GetDatum(usagecount_avg);
+ }
+ else
+ {
+ nulls[4] = true;
+ }
```

Why compute usagecount_avg twice? 

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCH] Introduce array_shuffle() and array_sample()
Next
From: Melih Mutlu
Date:
Subject: Re: Summary function for pg_buffercache