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

torikoshia <torikoshia@oss.nttdata.com>

From: torikoshia <torikoshia@oss.nttdata.com>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, bharath.rupireddyforpostgres@gmail.com
Cc: pgsql-hackers@postgresql.org
Date: 2023-10-31T07:26:18Z
Lists: pgsql-hackers
On Mon, Oct 30, 2023 at 5:46 PM Bharath Rupireddy 
<bharath.rupireddyforpostgres@gmail.com> wrote:

Thanks for the comments!

> Isn't calling pg_stat_reset_shared() for all stats types helping you
> out? Is there any problem with it? Can you be more specific about the
> use-case?

Yes, calling pg_stat_reset_shared() for all stats types can do what I 
wanted to do.
But calling it with 6 different parameters seems tiresome and I thought 
it would be convenient to have a parameter to delete all cluster-wide 
statistics at once.

I may be wrong, but I imagine that it's more common to want to delete 
all of the statistics for an entire cluster rather than just a portion 
of it.


> IMV, I don't see any point for adding another pseudo (rather
> non-existent) shared stats target which might confuse users - it's
> easy to specify pg_stat_reset_shared('all'); to clear things out when
> someone actually doesn't want to reset all - an accidental usage of
> the 'all' option will reset all shared memory stats.

I once considered changing the pg_stat_reset_shared() to delete all 
stats when called without parameters like pg_stat_statements_reset(), 
but gave it up since it can confuse users as you described.

I was hoping that the need to specify 'all' would remind users that the 
target can be specified individually.

-- 
Regards,

--
Atsushi Torikoshi
NTT DATA Group Corporation



Commits

  1. Add target "slru" to pg_stat_reset_shared()

  2. doc: Improve description of targets for pg_stat_reset_shared()

  3. Add support for pg_stat_reset_slru without argument

  4. Add ability to reset all shared stats types in pg_stat_reset_shared()