Simon Riggs wrote
> ISTM we could do some of that with another GUC, lets call it
> prepare_once = on. The system default is to have a prepared statement
> bound to a plan on its first parameter bind. If we set this to "off",
> then the statement will replan each time we bind. This would give us
> both flexibility and predictability. (As ever, someone suggest a
better
> name?).
>
We call it deferred optimization.
Do you really stop at the first parameter? What if it couldn't possibly
affect the plan (<col> like '%M%', or <col> is not involved in an
index)? You can continue to plan up until the first parameter that can
affect the plan. At that point, you save off the plan, and when you get
actual values (on the execute command), continue with the planning. You
can do the same thing with correlated subqueries
Mike Pollard
SUPRA Server SQL Engineering and Support
Cincom Systems, Inc.