Re: Improve pg_stat_statements scalability - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: Improve pg_stat_statements scalability
Date
Msg-id 20260702.152439.283442361339603199.horikyota.ntt@gmail.com
Whole thread
List 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



pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: Update EnableTimeoutParams timeout type comment
Next
From: Shlok Kyal
Date:
Subject: Re: Include sequences in publications created by pg_createsubscriber