From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix thinko in previous patch for optimizing EXISTS-within-EXISTS |
Date: | 2011-06-20 19:05:09 |
Message-ID: | E1QYjmX-0006cv-Qw@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix thinko in previous patch for optimizing EXISTS-within-EXISTS.
When recursing after an optimization in pull_up_sublinks_qual_recurse, the
available_rels value passed down must include only the relations that are
in the righthand side of the new SEMI or ANTI join; it's incorrect to pull
up a sub-select that refers to other relations, as seen in the added test
case. Per report from BangarRaju Vadapalli.
While at it, rethink the idea of recursing below a NOT EXISTS. That is
essentially the same situation as pulling up ANY/EXISTS sub-selects that
are in the ON clause of an outer join, and it has the same disadvantage:
we'd force the two joins to be evaluated according to the syntactic nesting
order, because the lower join will most likely not be able to commute with
the ANTI join. That could result in having to form a rather large join
product, whereas the handling of a correlated subselect is not quite that
dumb. So until we can handle those cases better, #ifdef NOT_USED that
case. (I think it's okay to pull up in the EXISTS/ANY cases, because SEMI
joins aren't so inflexible about ordering.)
Back-patch to 8.4, same as for previous patch in this area. Fortunately
that patch hadn't made it into any shipped releases yet.
Branch
------
REL9_1_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/6c560bef763f562a38fc629e54d0e20673efb9c1
Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 26 ++++++++++++++++----------
src/test/regress/expected/subselect.out | 12 ++++++++++++
src/test/regress/sql/subselect.sql | 9 +++++++++
3 files changed, 37 insertions(+), 10 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2011-06-20 20:20:57 | Re: Re: [COMMITTERS] pgsql: Fixed string in German translation that causes segfault. |
Previous Message | Alvaro Herrera | 2011-06-20 17:13:52 | Re: Re: [COMMITTERS] pgsql: Fixed string in German translation that causes segfault. |