where clause + function, execution order

From: Sorin Dudui <sd(at)wigeogis(dot)com>
To: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: where clause + function, execution order
Date: 2011-11-11 15:38:43
Message-ID: 13DE38ECCB7CE74890E7150A7CCB610D3642DD47@exc1.wigeo.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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'

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?

Thank you,
Sorin

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Julius Tuskenis 2011-11-11 15:54:00 Re: where clause + function, execution order
Previous Message Tom Lane 2011-11-11 15:36:26 Re: avoiding seq scans when two columns are very correlated