Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id B4D231064878 for ; Fri, 11 Nov 2011 12:00:04 -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 25174-06 for ; Fri, 11 Nov 2011 15:59:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by mail.postgresql.org (Postfix) with ESMTP id 554A91064877 for ; Fri, 11 Nov 2011 11:59:55 -0400 (AST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by mail.archonet.com (Postfix) with ESMTP id E5E1F7C041; Fri, 11 Nov 2011 15:59:48 +0000 (GMT) Message-ID: <4EBD4675.2060604@archonet.com> Date: Fri, 11 Nov 2011 15:59:49 +0000 From: Richard Huxton User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Lightning/1.0b2 Thunderbird/3.1.15 MIME-Version: 1.0 To: Julius Tuskenis CC: pgsql-performance@postgresql.org Subject: Re: where clause + function, execution order References: <13DE38ECCB7CE74890E7150A7CCB610D3642DD47@exc1.wigeo.lan> <4EBD4518.5070508@nsoft.lt> In-Reply-To: <4EBD4518.5070508@nsoft.lt> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.918 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RDNS_DYNAMIC=0.982 X-Spam-Level: X-Archive-Number: 201111/140 X-Sequence-Number: 45651 On 11/11/11 15:54, Julius Tuskenis wrote: > On 2011.11.11 17:38, Sorin Dudui wrote: >> I have the following function: >> >> CREATE OR REPLACE FUNCTION xxx(text) [snip] >> LANGUAGE sql STABLE > Function execute plan is prepared when creating it, so the "where" > clause should check the function result not altering its execution.. Not true for SQL functions. They can be inlined, but I'm not sure if this one will be. What does EXPLAIN ANALYSE show for this query? -- Richard Huxton Archonet Ltd