Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3CEC46322A7 for ; Thu, 27 May 2010 17:27:21 -0300 (ADT) 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 43904-08 for ; Thu, 27 May 2010 20:27:13 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id 4A016632266 for ; Thu, 27 May 2010 17:27:14 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Thu, 27 May 2010 15:27:12 -0500 Message-Id: <4BFE8F4F0200002500031BA2@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Thu, 27 May 2010 15:27:11 -0500 From: "Kevin Grittner" To: , "Carlo Stonebanks" Subject: Re: Does FILTER in SEQSCAN short-circuit AND? References: In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.21 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/239 X-Sequence-Number: 38823 "Carlo Stonebanks" wrote: > SELECT * > FROM MyTable > WHERE foo = 'bar' AND MySlowFunc('foo') = 'bar' > > Let's say this required a SEQSCAN because there were no indexes to > support column foo. For every row where foo <> 'bar' would the > filter on the SEQSCAN short-circuit the AND return false right > away, or would it still execute MySlowFunc('foo') ? For that example, I'm pretty sure it will skip the slow function for rows which fail the first test. A quick test confirmed that for me. If you create a sufficiently slow function, you shouldn't have much trouble testing that yourself. :-) -Kevin