Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3CB26106487D for ; Fri, 11 Nov 2011 12:00:23 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 28156-02 for ; Fri, 11 Nov 2011 16:00:17 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id D51121064878 for ; Fri, 11 Nov 2011 12:00:16 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pABG0FFw005922; Fri, 11 Nov 2011 11:00:15 -0500 (EST) To: Sorin Dudui cc: "pgsql-performance@postgresql.org" Subject: Re: where clause + function, execution order In-reply-to: <13DE38ECCB7CE74890E7150A7CCB610D3642DD47@exc1.wigeo.lan> References: <13DE38ECCB7CE74890E7150A7CCB610D3642DD47@exc1.wigeo.lan> Comments: In-reply-to Sorin Dudui message dated "Fri, 11 Nov 2011 15:38:43 +0000" Date: Fri, 11 Nov 2011 11:00:15 -0500 Message-ID: <5921.1321027215@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/141 X-Sequence-Number: 45652 Sorin Dudui writes: > 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? EXPLAIN is your friend ... In this case the function looks inline-able, so reasonably recent versions of PG should do what you want. regards, tom lane