Re: track generic and custom plans in pg_stat_statements - Mailing list pgsql-hackers

From Andrei Lepikhov
Subject Re: track generic and custom plans in pg_stat_statements
Date
Msg-id 5f775987-8a93-452d-bb3f-a1de53836406@gmail.com
Whole thread Raw
In response to track generic and custom plans in pg_stat_statements  (Sami Imseih <samimseih@gmail.com>)
Responses Re: track generic and custom plans in pg_stat_statements
List pgsql-hackers
On 6/30/25 13:45, Sami Imseih wrote:
> rebased patch.
> 
> Only changes to the tests due to the revert of nested query
> tracking in f85f6ab051b
Thank you for your efforts.

I would like to share a few thoughts about this patch. First, I believe 
the 'status' field could be renamed to 'mode,' as it aligns better with 
the plan_cache_mode GUC name. Additionally, why introduce an unknown 
status? I can't foresee a scenario where it would be necessary, as we 
typically encounter either a custom or a generic plan during execution.

On a more general note, currently, CachedPlanSource does not refer to a 
custom version of the plan. However, it seems reasonable to implement 
this for better tracking. By adding a CachedPlanSource::cplan link, we 
can establish a connection to the entire PlanCache entry instead of only 
CachedPlan within a queryDesc and, consequently, make it accessible from 
the executor. This would give an access to statistics on costs and the 
number of replannings.

Furthermore, this could lead to interesting opportunities for 
extensions, such as resetting auto-mode decisions and planning 
statistics based on actual execution statistics, and manipulating 
generic/custom plan switching logic.

-- 
regards, Andrei Lepikhov



pgsql-hackers by date:

Previous
From: Rintaro Ikeda
Date:
Subject: Re: Suggestion to add --continue-client-on-abort option to pgbench
Next
From: Mircea Cadariu
Date:
Subject: Re: Saving stack space in nbtree's _bt_first function