Re: Add new option 'all' to pg_stat_reset_shared()

From: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>, boekewurm+postgres(at)gmail(dot)com
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Add new option 'all' to pg_stat_reset_shared()
Date: 2023-11-06 06:09:28
Message-ID: e784c0d54c849e86d69138883d12138f@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks all for the comments!

On Fri, Nov 3, 2023 at 5:17 AM Matthias van de Meent
<boekewurm+postgres(at)gmail(dot)com> wrote:
> Knowing that your metrics have a shared starting point can be quite
> valuable, as it allows you to do some math that would otherwise be
> much less accurate when working with stats over a short amount of
> time. I've not used these stats systems much myself, but skew between
> metrics caused by different reset points can be difficult to detect
> and debug, so I think an atomic call to reset all these stats could be
> worth implementing.

Since each stats, except wal_prefetch was reset acquiring LWLock,
attached PoC patch makes the call atomic by using these LWlocks.

If this is the right direction, I'll try to make wal_prefetch also take
LWLock.

On 2023-11-04 10:49, Andres Freund wrote:

> Yes, agreed. However, I'd suggest adding pg_stat_reset_shared(),
> instead of
> pg_stat_reset_shared('all') for this purpose.

In the attached PoC patch the shared statistics are reset by calling
pg_stat_reset_shared() not pg_stat_reset_shared('all').

--
Regards,

--
Atsushi Torikoshi
NTT DATA Group Corporation

Attachment Content-Type Size
v1-0001-WIP-Add-ability-to-reset-all-statistics-to-pg_sta.patch text/x-diff 6.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2023-11-06 06:14:00 Compiling warnings on old GCC
Previous Message Michael Paquier 2023-11-06 05:05:59 Re: Add recovery to pg_control and remove backup_label