From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: pgsql-performance@postgresql.org
To: Carlo Stonebanks <stonec.register@sympatico.ca>
Subject: Re: Does FILTER in SEQSCAN short-circuit AND?
Date: Thu, 27 May 2010 15:27:11 -0500
Message-ID: <4BFE8F4F0200002500031BA2@gw.wicourts.gov> (raw)
In-Reply-To: <hsv49v$312j$1@news.hub.org>
References: <hsv49v$312j$1@news.hub.org>
"Carlo Stonebanks" <stonec.register@sympatico.ca> 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
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: Kevin.Grittner@wicourts.gov, stonec.register@sympatico.ca
Subject: Re: Does FILTER in SEQSCAN short-circuit AND?
In-Reply-To: <4BFE8F4F0200002500031BA2@gw.wicourts.gov>
* 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