| From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
|---|---|
| To: | Sami Imseih <samimseih(dot)pg(at)gmail(dot)com> |
| Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Lukas Fittl <lukas(at)fittl(dot)com> |
| Subject: | Re: pgstat: Flush some statistics within running transactions, take 2 |
| Date: | 2026-09-01 12:19:34 |
| Message-ID: | apbC1nfa85slnxKR@bdtpg |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Mon, Aug 31, 2026 at 03:17:28PM -0500, Sami Imseih wrote:
> Here is v9- with:
Thanks!
=== 1
> 1/ to also pgStatFlushInProgress when we're-queueing
>
> pgstat_prep_pending_from_entry_ref(PgStat_EntryRef *entry_ref)
> {
> ...
> ....
> else if (pgStatFlushInProgress && entry_ref->flushed_this_pass)
> ...
> ...
> }
This fixes the case where the stale flag moves an entry before the new flush pass
starts.
That said, IIUC, the flag remains true from the previous pass until the entry
is visited in the new one. So, if an earlier callback updates an entry not yet
visited, pgstat_prep_pending_from_entry_ref() treats it as already visited in
the current pass.
I wonder if the flags should be reset before starting the scan?
=== 2
+SELECT seq_scan - :seq_scan_before AS seq_scan_delta,
+ seq_tup_read - :seq_tup_read_before AS seq_tup_read_delta,
+ n_tup_ins - :n_tup_ins_before AS n_tup_ins_delta,
+ n_tup_upd - :n_tup_upd_before AS n_tup_upd_delta,
+ n_tup_hot_upd + n_tup_newpage_upd <= n_tup_upd AS upd_counts_ok
+ FROM pg_stat_user_tables WHERE relname = 'partial_flush';
That would also succeed if both counters were zero. Since the test performs exactly
one update on a table without indexes, their sum should increase by one. Could
we record its value before the transaction and check that delta instead?
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-09-01 12:23:16 | Re: Replace px_memset() with explicit_bzero() |
| Previous Message | Radim Marek | 2026-09-01 12:10:27 | Re: RANGE partition pruning can still exclude the default partition |