Hi all,
I’d like to propose a patch that introduces a referenced generic plan mode.
The patch adds:
new EXPLAIN option REF_GENERIC_PLAN
(not allowed with ANALYZE);
new plan_cache_mode
values ref_auto
and force_ref_generic_plan
;
a flag to prevent constant folding of Params when building a generic plan.
Generic and custom plan behavior stays unchanged unless the new option is used.
Similar ideas exist in other systems: Oracle (Adaptive Cursor Sharing), SQL Server (Parameter Sensitive Plan Optimization), and Db2 (REOPT).
I’ve attached the patch and a minimal regression test.
Best regards,
Vlada Pogozhelskaya