On Wed, Sep 19, 2012 at 1:26 PM, Tom Lane <t...@sss.pgh.pa.us> wrote: > Robert Haas <robertmh...@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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers