From: Julius Tuskenis <julius@nsoft.lt>
To: pgsql-performance@postgresql.org
Subject: Re: where clause + function, execution order
Date: Fri, 11 Nov 2011 17:54:00 +0200
Message-ID: <4EBD4518.5070508@nsoft.lt> (raw)
In-Reply-To: <13DE38ECCB7CE74890E7150A7CCB610D3642DD47@exc1.wigeo.lan>
References: <13DE38ECCB7CE74890E7150A7CCB610D3642DD47@exc1.wigeo.lan>
Hello,
On 2011.11.11 17:38, Sorin Dudui wrote:
>
> Hi,
>
> I have the following function:
>
> ===============================
>
> CREATE OR REPLACE FUNCTION xxx(text)
>
> RETURNS SETOF vvvvv AS
>
> $BODY$
>
> select a.x, a.y,
>
> CASE
>
> WHEN strpos($1,b.x) > 0
>
> THEN b.x
>
> ELSE NULL
>
> END AS mp_hm
>
> from a LEFT JOIN b ON a.id=b.id
>
> $BODY$
>
> LANGUAGE sql STABLE
>
> COST 1000
>
> ROWS 10000;
>
> ===============================
>
> which I call as:
>
> select * from xxx(‘test0|test1‘) where a.x = ‘value’
>
You should get an error as there is no "a" in this statement...
>
> I am wondering when the where clause (a.x = ‘value’) is executed.
> After the select statement in the function finishes? Or is it appended
> at the select statement in the function?
>
Function execute plan is prepared when creating it, so the "where"
clause should check the function result not altering its execution..
--
Julius Tuskenis
Head of the programming department
UAB nSoft
mob. +37068233050
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: julius@nsoft.lt
Subject: Re: where clause + function, execution order
In-Reply-To: <4EBD4518.5070508@nsoft.lt>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox