Hi hackers,
I am currently exploring whether it is possible to cache a plan generated by the PostgreSQL planner and reuse it across
laterexecutions.
I understand that there are existing mechanisms like PREPARE/EXECUTE and CachedPlan in plancache.c, but these are tied
toprepared statements and session-level usage. My interest is more on the research side:
- Is there any supported (or experimental) way to serialize a Plan or PlannedStmt structure and reload it in a future
execution,bypassing the planner?
- If not, would it make sense to extend the existing CachedPlan mechanism to support serialization/deserialization, or
arethere known architectural reasons why this approach is discouraged?
- Any relevant references in the source code (planner, plancache.c, executor) that I should study would be very
helpful.
The motivation is research-oriented: I want to experiment with plan persistence as a way to reduce planning overhead
andstudy trade-offs of reusing cached plans.
Thanks a lot for your guidance!
Best regards,
Xuan Chen