Re: dynamically generated SQL and planner/performance - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: dynamically generated SQL and planner/performance
Date
Msg-id 20080322204756.GE13206@alvh.no-ip.org
Whole thread Raw
In response to Re: dynamically generated SQL and planner/performance  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
List pgsql-general
Ivan Sergio Borgonovo wrote:

> But does this cascade to all the nested functions?
>
> functionA {
>   execute functionB {
>     sql statement
>   }
> }
>
> As my previous example I've a functionA that build up a statement that
> call another functionB that just contain static sql statements.

Each function is planned and cached independently, regardless of how
they are called.  In fact the previous sentence does not really make
sense, because what truly happens is that each _sentence_ within each
function is planned and cached independently.


> If it's something like
> execute select res fron functionB() into _res;
> since the "complicated" part is inside each functionB I shouldn't
> expect any great loss.
>
> Is it?

Correct -- the part that's being discarded each time here is the SELECT
that calls up functionB, not functionB's statements themselves.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-general by date:

Previous
From: Michael Meskes
Date:
Subject: Re: --enable-thread-safety bug
Next
From: Steve Clark
Date:
Subject: Re: --enable-thread-safety bug