Oliver Jowett wrote:
> What happens if (for example) DateStyle changes between the two parses?
From my original email:
This is the common case of a more general problem: a query plan depends
on various parts of the environment at plan-creation time. That
environment includes the definitions of database objects, but also GUC
variables (most importantly search_path, but also optimizer-tuning
variables for example), the state of database statistics, and so on.
I'll leave resolution of the more general problem to someone else -- I
think if we can manage to invalidate plans automatically when dependent
objects change, that's better than nothing.
I'm don't think recreating the plan from the query string changes this
fundamentally -- the interaction between (for example) GUC variables and
prepared plans will likely not be well-defined (which will be no worse
than it is today).
(It might be plausible to work something out where a backend-local SET
of some subset of the GUC variables flushes all the cached query plans,
but I'm don't have any plans to look at it myself.)
-Neil