Re: Flush some statistics within running transactions

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Subject: Re: Flush some statistics within running transactions
Date: 2026-02-02 17:19:43
Message-ID: aYDcr4wJVCusfMje@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Feb 02, 2026 at 04:31:48PM +0900, Michael Paquier wrote:
> On Sat, Jan 31, 2026 at 11:16:03AM -0600, Sami Imseih wrote:
> > Also, the anytime flush callback does not need to check if there are
> > any variable-numbered stats to flush. This will not be needed as
> > it is in v4-0004
> >
> > ```
> > + /*
> > + * Check if there are any non-transactional stats to flush. Avoid
> > + * unnecessarily locking the entry if nothing accumulated.
> > + */
> > + if (!(lstats->counts.numscans > 0 ||
> > + lstats->counts.tuples_returned > 0 ||
> > + lstats->counts.tuples_fetched > 0 ||
> > + lstats->counts.blocks_fetched > 0 ||
> > + lstats->counts.blocks_hit > 0))
> > + return true;
> > ```
>
> I think that this kind of check may finish by being expensive.
> Reducing the number of fields to check for a non-flushing state, if
> required, would be preferrable.

Done, in v5 just shared up-thread.

Oh and I forgot to mention that with the new design in v5, then the fix for
the issue discovered by Masao-san is not needed anymore (and so has been removed
from 0001).

Regards,

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Banck 2026-02-02 17:31:56 [patch] Add process title to test_shm_mq worker
Previous Message Bertrand Drouvot 2026-02-02 17:16:30 Re: Flush some statistics within running transactions