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>, Tom Lane <tgl@sss.pgh.pa.us>, 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-31T07:10:00Z
Lists: pgsql-hackers
On 30/7/2025 22:09, Sami Imseih wrote:
> The concepts of custom and generic plan types are associated with plan caches,
> so they cannot have a different source. right?
That is exactly what confused me: what does the 'origin' of the plan 
mean? See the comment:

 > PlannedStmtOrigin identifies from where a PlannedStmt comes from.

The first thing that comes to mind after reading this comment is a 
subsystem, such as the SPI, simple or extended protocol, or an 
extension. Another meaning is a type of plan, such as 'custom', 
'generic', or 'referenced'. As I see, here is a bit different 
classification used, not so obvious, at least for me.

-- 
regards, Andrei Lepikhov



Commits

  1. pg_stat_statements: Add counters for generic and custom plans

  2. Rename CachedPlanType to PlannedStmtOrigin for PlannedStmt

  3. Introduce field tracking cached plan type in PlannedStmt