Richard Huxton wrote:
> So - gain by not re-planning on every call, but maybe lose because your plan
> is not so precise.
>
> Of course, any queries you build dynamically and run via EXECUTE will have to
> be planned each time.
>
This question gets even more complex in 7.4, where many simple SQL
functions will get inlined, and library preloading is available to speed
that first PL/pgSQL call.
I think the best way to answer this question for any particular function
is to try it both ways (if the function *can* be written as a SQL
function) and see for yourself. And if you do this in 7.3, redo it when
you upgrade to 7.4.
HTH,
Joe