Re: track generic and custom plans in pg_stat_statements
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrei Lepikhov <lepihov@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, Sami Imseih <samimseih@gmail.com>,
Greg Sabino Mullane <htamfids@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>,
Nikolay Samokhvalov <nik@postgres.ai>,
Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
Date: 2025-07-24T15:05:10Z
Lists: pgsql-hackers
Andrei Lepikhov <lepihov@gmail.com> writes: > I see you have chosen a variant with a new enum instead of a pointer to > a plan cache entry. I wonder if you could write the arguments > supporting this choice? Pointing to a plan cache entry would often mean that the data structure as a whole is circular (since a plan cache entry will have a pointer to a plan). That would in particular make it unsafe for the plan to protect its pointer by incrementing the cache entry's refcount --- the assemblage could never go away. So I concur with Michael that what you propose is a bad idea. 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 replanning events. regards, tom lane
Commits
-
pg_stat_statements: Add counters for generic and custom plans
- 3357471cf9f5 19 (unreleased) landed
-
Rename CachedPlanType to PlannedStmtOrigin for PlannedStmt
- e125e360020a 19 (unreleased) landed
-
Introduce field tracking cached plan type in PlannedStmt
- 719dcf3c4226 19 (unreleased) landed