Re: Improve pg_stat_statements scalability

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: samimseih(at)gmail(dot)com
Cc: michael(at)paquier(dot)xyz, lukas(at)fittl(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve pg_stat_statements scalability
Date: 2026-07-02 06:24:39
Message-ID: 20260702.152439.283442361339603199.horikyota.ntt@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello.

Thank you for the new version.

* Ignore entries that didn't accumulate any actual counts, such as
- * indexes that were opened by the planner but not used.
+ * indexes that were opened by the planner but not used. With
+ * in-transaction flushing an entry may be flushed multiple times, so keep
+ * it pending if it has active transaction state and commit will merge
+ * counters into it.
*/
if (pg_memory_is_all_zeros(&lstats->counts,
sizeof(struct PgStat_TableCounts)))
- return true;
+ return (lstats->trans == NULL);

One of my previous comments was that this change makes the callback
return value carry two different meanings. Since whether lstats->trans
is NULL is purely part of the calling context and not derived from the
callback's own work, I still think it is cleaner to keep
pgstat_relation_flush_cb() unchanged and let the caller handle that
distinction instead.

Regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Shlok Kyal 2026-07-02 06:29:45 Re: Include sequences in publications created by pg_createsubscriber
Previous Message John Naylor 2026-07-02 06:23:01 Re: Update EnableTimeoutParams timeout type comment