Re: dynamically generated SQL and planner/performance

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: dynamically generated SQL and planner/performance
Date: 2008-03-22 20:47:56
Message-ID: 20080322204756.GE13206@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Clark 2008-03-22 20:58:28 Re: --enable-thread-safety bug
Previous Message Michael Meskes 2008-03-22 20:11:12 Re: --enable-thread-safety bug