Re: track generic and custom plans in pg_stat_statements

Sami Imseih <samimseih@gmail.com>

From: Sami Imseih <samimseih@gmail.com>
To: Nikolay Samokhvalov <nik@postgres.ai>
Cc: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>, Greg Sabino Mullane <htamfids@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-06-03T03:31:25Z
Lists: pgsql-hackers

Attachments

> Now, one thing I don't like is the fact that the columns stats_since
> and minmax_stats_since
> are in between counters all of the sudden. I think we either need to
> move them to
> the front of the view, after the query field  or within this patch
> move them after the
> new generic/custom plan counters. I prefer the former since we do it
> once in a major version
> and do not have to worry about it once new counters are added.
>
> It just feels odd that they sit in between the counters as they have a
> high level purpose.

It occurred to me after a bit that we added the parallel_workers_to_launch and
parallel_workers_launched fields after stats_since and minmax_stats_since
were introduced, but the stats related fields were kept at the end. So,
I will do the same with the new counters. I still don't like the stats fields
being at the end, but that could still be taken up after.

See v8 with the field names reorganized.

--
Sami Imseih
Amazon Web Services (AWS)

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