]> granicus.if.org Git - postgresql/commit
Fix pull_up_sublinks' failure to handle nested pull-up opportunities.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 2 May 2011 19:56:36 +0000 (15:56 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 2 May 2011 19:57:28 +0000 (15:57 -0400)
commitdcc685debb02c507b88aa8052f9e6334a7c3f830
treec8db1d89f77c7e3b020fa4777d57702834647915
parent52897e54db1000f2fa45b31e02eb252dd0573516
Fix pull_up_sublinks' failure to handle nested pull-up opportunities.

After finding an EXISTS or ANY sub-select that can be converted to a
semi-join or anti-join, we should recurse into the body of the sub-select.
This allows cases such as EXISTS-within-EXISTS to be optimized properly.
The original coding would leave the lower sub-select as a SubLink, which
is no better and often worse than what we can do with a join.  Per example
from Wayne Conrad.

Back-patch to 8.4.  There is a related issue in older versions' handling
of pull_up_IN_clauses, but they're lame enough anyway about the whole area
that it seems not worth the extra work to try to fix.
src/backend/optimizer/plan/subselect.c
src/backend/optimizer/prep/prepjointree.c