Re: [PATCH] Optionally record Plan IDs to track plan changes for a query
Jeremy Schneider <schneider@ardentperf.com>
From: Jeremy Schneider <schneider@ardentperf.com>
To: Lukas Fittl <lukas@fittl.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Marko M
<marko@pganalyze.com>, Sami Imseih <samimseih@gmail.com>
Date: 2025-01-07T06:35:25Z
Lists: pgsql-hackers
On Thu, 2 Jan 2025 12:46:04 -0800 Lukas Fittl <lukas@fittl.com> wrote: > this proposed patch set adds: > > 1. An updated in-core facility to optionally track Plan IDs based on > hashing the plan nodes during the existing treewalk in setrefs.c - > controlled by the new "compute_plan_id" GUC > 2. An example user of plan IDs with a new pg_stat_plans extension in > contrib, that also records the first plan text with EXPLAIN (COSTS > OFF) > > My overall perspective is that (1) is best done in-core to keep > overhead low, whilst (2) could be done outside of core (or merged > with a future pg_stat_statements) and is included here mainly for > illustration purposes. And 2025 is starting with a bang! Nice to see this email! Being able to collect telemetry that indicates when plan changes happened would be very useful. The specifics of how a plan ID is generated are going to have some edge cases (as you noted) I concur that the ideal place for this to eventually land would be alongside queryid in pg_stat_activity -Jeremy
Commits
-
doc: Update header file mention for CompareType
- b39013b7b1b1 19 (unreleased) cited
-
Allow plugins to set a 64-bit plan identifier in PlannedStmt
- 2a0cd38da5cc 18.0 landed
-
Fix indentation of comment in plannodes.h
- c9238ad85325 18.0 landed
-
Reformat node comments in plannodes.h
- 3d17d7d7fb7a 18.0 landed
-
injection_points: Add routine able to drop all stats
- a632cd354d35 18.0 landed
-
Add pgstat_drop_matching_entries() to pgstats
- ce5c620fb625 18.0 landed
-
Move pg_stat_statements query jumbling to core.
- 5fd9dfa5f50e 14.0 cited