pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add stats kind filter to pgstat_drop_matching_entries()
Date: Thu, 05 Nov 2026 00:14:01 +0000
Message-ID: <E1xOl7C-00000000EhB-0Hy0@gemulon.postgresql.org> (raw)

Add stats kind filter to pgstat_drop_matching_entries()

pgstat_drop_matching_entries() scans all variable-numbered stats hash
tables.  Some callers already know which stats kind they want to scan,
and such a kind may have its own dshash.

pgstat_drop_matching_entries() is upgraded with a stats kind argument.
PGSTAT_KIND_INVALID preserves the existing all-kinds behavior, while a
specific kind scans the hash mapped to that kind.  When that hash is
shared by multiple stats kinds, entries are filtered by kind before
invoking the match callback, or applying the drop-all behavior if no
match callback is defined.

An immediate motivation is pg_stat_statements, where some follow-up work
can use this to drop matching entries from its stats kind, without
having to scan all the stats hastables.

Author: Sami Imseih <samimseih.pg@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAN12+YL7SrAwzMpzfNLrVcy=w5L03p7czyO73RfS06kmdqs_fw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/31f89191ff7b22b6c69ae5f3c6ab48c5d8bb0f2b

Modified Files
--------------
src/backend/utils/activity/pgstat_shmem.c          | 38 +++++++++++++++---
src/include/utils/pgstat_internal.h                |  3 +-
.../test_custom_stats/t/001_custom_stats.pl        | 34 +++++++++++++++-
.../test_custom_var_stats--1.0.sql                 |  5 +++
.../test_custom_stats/test_custom_var_stats.c      | 45 +++++++++++++++++++++-
5 files changed, 116 insertions(+), 9 deletions(-)



Message-ID: <E1xOl7C-00000000EhB-0Hy0@gemulon.postgresql.org>
Permalink:  ../E1xOl7C-00000000EhB-0Hy0@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xOl7C-00000000EhB-0Hy0@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Add stats kind filter to pgstat_drop_matching_entries()
  In-Reply-To: <E1xOl7C-00000000EhB-0Hy0@gemulon.postgresql.org>
  References: <E1xOl7C-00000000EhB-0Hy0@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox