Re: pgstat: Flush some statistics within running transactions, take 2

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Lukas Fittl <lukas(at)fittl(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Re: pgstat: Flush some statistics within running transactions, take 2
Date: 2026-08-19 03:50:48
Message-ID: CAA5RZ0vBsc+kodzEgGKov+321ky1BYGKskaSph=Q=FsYzDaKjg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks!

> FWIW, I'd vote for an helper comparing the five counters that can be
> flushed immediately. There are only five, and adding another one would
> already require updating the merge and baseline logic.
>
> That would keep the policy local to pgstat_relation_flush_cb() and avoid
> making PgStat_TableCounts field order part of the flush logic.

Fair point.

I was looking at it less as a one-off fix here and more as a reusable approach
for kinds that mix the two. I'd rather not end up with a
field-by-field compare in
every flush callback, and just keep it a single memcmp(). I went with grouping
the counters and comparing by offset mainly because it was the least
friction to
get there, although not the cleanest.

What about splitting the transaction-safe and non-transaction-safe counters
into two nested structs inside PgStat_TableCounts? That puts the boundary in
the type instead of an offset, and each group is still one memcmp().

> That said, let's see what Michael thinks.

+1

--
Sami Imseih
Amazon Web Services (AWS)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-08-19 04:58:01 Re: pgstat: Flush some statistics within running transactions, take 2
Previous Message Fujii Masao 2026-08-19 03:47:29 Re: Fix small psql slash option leaks