Re: track generic and custom plans in pg_stat_statements
Andrei Lepikhov <lepihov@gmail.com>
From: Andrei Lepikhov <lepihov@gmail.com>
To: Sami Imseih <samimseih@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>,
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-22T20:12:04Z
Lists: pgsql-hackers
On 7/22/25 19:13, Sami Imseih wrote: >> It may be more efficient to set the is_generic_plan option at the top >> plan node (PlannedStmt) and reference it wherever necessary. To identify >> a cached plan, we may consider pushing the CachedPlan/CachedPlanSource >> pointer down throughout pg_plan_query and maintaining a reference to the >> plan (or simply setting a boolean flag) at the same location — inside >> the PlannedStmt. > > We will need a field to store an enum. let's call it CachedPlanType > with the types of cached plan. We need to be able to differentiate > when cached plans are not used, so a simple boolean is not > sufficient. Sure. But I modestly hope you would add a CachedPlanSource pointer solely to the PlannedStmt and restructure it a little as we discussed above. And no new structures are needed. Am I wrong? -- regards, Andrei Lepikhov
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