Re: track generic and custom plans in pg_stat_statements

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Andrei Lepikhov <lepihov(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Nikolay Samokhvalov <nik(at)postgres(dot)ai>, Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
Subject: Re: track generic and custom plans in pg_stat_statements
Date: 2025-07-24 17:43:47
Message-ID: 1673684.1753379027@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Sami Imseih <samimseih(at)gmail(dot)com> writes:
>> That is not to say that I think 719dcf3c4 was a good idea: it looks
>> rather useless from here. It seems to me that the right place to
>> accumulate these sorts of stats is in CachedPlanSources, and I don't
>> see how this helps. What likely *would* help is some hooks in
>> plancache.c for pg_stat_statements to connect into so it can count

> One possible hook for accumulating custom and generic plans per
> queryId would be inside GetCachedPlan. However, this would require
> calling pgss_store an extra time, in addition to ExecutorEnd, every time
> GetCachedPlan is executed, which could introduce non-negligible
> overhead.

Only if you insist that the way to handle this is to call pgss_store
at that time. I'd be inclined to think about having some transient
process-local data structure that can remember the info until
ExecutorEnd. But the plan tree is not the right place, because of
the circularity problem.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-07-24 17:50:17 Re: roles management problem after upgrading in PG 17
Previous Message Tom Lane 2025-07-24 17:24:35 Re: HASH_FIXED_SIZE flag gets lost when attaching to existing hash table