| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Add stats kind filter to pgstat_drop_matching_entries() |
| Date: | 2026-11-05 00:14:01 |
| Message-ID: | E1xOl7C-00000000EhB-0Hy0@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(dot)pg(at)gmail(dot)com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2026-11-05 04:25:46 | pgsql: Avoid resetting subscription two_phase state to pending when alr |
| Previous Message | Amit Langote | 2026-11-04 23:57:36 | pgsql: SQL/JSON: Fix ON EMPTY/ERROR state leakage on NULL input |