Re: Invalid optimization of VOLATILE function in WHERE clause? - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Invalid optimization of VOLATILE function in WHERE clause?
Date
Msg-id CA+TgmobUsLZZ2-j9e1tDrw6csynUDTF1ZGz-cg9nVkAC1VWx4g@mail.gmail.com
Whole thread Raw
In response to Re: Invalid optimization of VOLATILE function in WHERE clause?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Wed, Sep 19, 2012 at 1:26 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
>> It still seems like awfully weird behavior.
>
> Why?  The WHERE condition relates only to the output of the _stats
> subquery, so why shouldn't it be evaluated there, rather than after
> the join?

Because my mental model (and apparently that of the OP) is that the
WHERE clause gets evaluated separately for each row.  Obviously in
many cases that can be optimized without changing the results, but not
in this case.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Removal of AcceptInvalidationMessages broke things
Next
From: "Kevin Grittner"
Date:
Subject: Re: Invalid optimization of VOLATILE function in WHERE clause?