Hi hackers, I am currently exploring whether it is possible to cache a plan generated by the PostgreSQL planner and reuse it across later executions.
I understand that there are existing mechanisms like PREPARE/EXECUTE and CachedPlan in plancache.c, but these are tied to prepared 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 are there 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 and study trade-offs of reusing cached plans. Thanks a lot for your guidance! Best regards, Xuan Chen
