Re: Redesign per-backend statistics

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Sami Imseih <samimseih(at)gmail(dot)com>
Subject: Re: Redesign per-backend statistics
Date: 2026-11-09 09:16:39
Message-ID: avGPd/KKBp938gUq@bdtpg
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, Nov 05, 2026 at 08:17:22AM +0000, Bertrand Drouvot wrote:
> Hi,
>
> On Thu, Nov 05, 2026 at 02:19:41PM +0900, Michael Paquier wrote:
>
> > +# Verify that a statistics snapshot excludes backends that started after the
> > +# snapshot was created.
> > +my $snapshot_session = $node->background_psql($connect_db);
> >
> > Hmm. Not sure that this one is worth the cycles spent for it.
>
> This one covers a real bug that I hit while working on the re-design, so it feel
> safer for me to keep it. That said if you feel strongly about it we could get rid
> of it.

PFA the new version (I kept the above test, but I can get rid of it if you feel
strongly about it). Compared to v4, the main change is in 0002: as you suggested,
the generic infrastructure now iterates over the stats kind IDs when transferring
per-backend statistics at process exit, ProcNumber reuse and clean shutdown.

As a result, 0003-0005 no longer add direct WAL, lock and I/O accumulation calls.
0006 also renames pgstat_per_backend.c to pgstat_backend.c after removing the
existing PGSTAT_KIND_BACKEND implementation.

Also, as mentioned up-thread, support for custom per-backend statistics is left
for a follow-up.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v5-0001-pgstat-add-tests-for-per-backend-statistics.patch text/x-diff 18.3 KB
v5-0002-pgstat-add-new-infrastructure-for-per-backend-sta.patch text/x-diff 25.8 KB
v5-0003-pgstat-move-WAL-statistics-to-new-per-backend-inf.patch text/x-diff 19.0 KB
v5-0004-pgstat-move-lock-statistics-to-new-per-backend-in.patch text/x-diff 19.5 KB
v5-0005-pgstat-move-I-O-statistics-to-new-per-backend-inf.patch text/x-diff 31.0 KB
v5-0006-pgstat-remove-PGSTAT_KIND_BACKEND.patch text/x-diff 36.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2026-11-09 09:28:32 Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore
Previous Message Etsuro Fujita 2026-11-09 09:15:46 Re: Clarify wait versus poll behavior in ExecAppendAsyncEventWait