Re: Does FILTER in SEQSCAN short-circuit AND? - Mailing list pgsql-performance

From Kevin Grittner
Subject Re: Does FILTER in SEQSCAN short-circuit AND?
Date
Msg-id 4BFE8F4F0200002500031BA2@gw.wicourts.gov
Whole thread Raw
In response to Does FILTER in SEQSCAN short-circuit AND?  ("Carlo Stonebanks" <stonec.register@sympatico.ca>)
Responses Performance costs of various PL languages  ("Carlo Stonebanks" <stonec.register@sympatico.ca>)
List pgsql-performance
"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

pgsql-performance by date:

Previous
From: "Carlo Stonebanks"
Date:
Subject: Does FILTER in SEQSCAN short-circuit AND?
Next
From: Craig James
Date:
Subject: Re: Does FILTER in SEQSCAN short-circuit AND?