Re: Does FILTER in SEQSCAN short-circuit AND?

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <pgsql-performance(at)postgresql(dot)org>, "Carlo Stonebanks" <stonec(dot)register(at)sympatico(dot)ca>
Subject: Re: Does FILTER in SEQSCAN short-circuit AND?
Date: 2010-05-27 20:27:11
Message-ID: 4BFE8F4F0200002500031BA2@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Carlo Stonebanks" <stonec(dot)register(at)sympatico(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Craig James 2010-05-27 21:13:50 Re: Does FILTER in SEQSCAN short-circuit AND?
Previous Message Slava Moudry 2010-05-27 19:34:15 how to force hashaggregate plan?