Re: track generic and custom plans in pg_stat_statements

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Sami Imseih <samimseih@gmail.com>
Cc: Andrei Lepikhov <lepihov@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-24T07:03:09Z
Lists: pgsql-hackers

Attachments

On Wed, Jul 23, 2025 at 12:15:06PM +0900, Michael Paquier wrote:
> A small thing that would be cleaner is to split the patch into two
> parts: one for the in-core backend addition and a second for PGSS.
> Code paths are different, so it's simple to do.

I have been looking at the backend part of the change to add the
cached plan type to PlannedStmt, and found the concept clean.  I have
moved the definition of the new enum to plannodes.h, tweaked a couple
of comments and the result seemed OK, so applied this part.

Attached is the rest of the patch for PGSS, not really reviewed yet.
I have noticed while going through it that pgssCachedPlanMode was not
required.
--
Michael

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