On Monday 19 March 2007 05:07 Tom Lane wrote: > Vincenzo Romano <vincenzo.romano@xxxxxxxxx> writes: > > How can I delay the query planner decisions until the actual query is to > > be done inside the function body? > > Use plpgsql's EXECUTE. AFAIR there is no way in a SQL-language function. > > regards, tom lane The body of a function is *always* treated by the planner as if it were a dynamically created query. The fact we all use the "$$"s (or also the 's) around the function body tells it all. The PREPARE requires every session to do it upon connections, because prepared statements are managed on a per-session basis. What I don't understand is why the planner gets passed by during those queries while it is at full steam during the "normal" queries. But this could be due to my ignorance! :-) -- Vincenzo Romano ---- Maybe Computers will never become as intelligent as Humans. For sure they won't ever become so stupid. [VR-1987]