Restructure building of join relation targetlists so that a join plan
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 29 Jun 2003 23:05:05 +0000 (23:05 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 29 Jun 2003 23:05:05 +0000 (23:05 +0000)
commit0240c635437232ae86fc0f1565941edcb8347d79
treec43353f5bc80eb3f75093429977aef8e13fb917f
parent738ba7ce22bfa8604eb74f2e3ad9bb6d78abc48c
Restructure building of join relation targetlists so that a join plan
node emits only those vars that are actually needed above it in the
plan tree.  (There were comments in the code suggesting that this was
done at some point in the dim past, but for a long time we have just
made join nodes emit everything that either input emitted.)  Aside from
being marginally more efficient, this fixes the problem noted by Peter
Eisentraut where a join above an IN-implemented-as-join might fail,
because the subplan targetlist constructed in the latter case didn't
meet the expectation of including everything.
Along the way, fix some places that were O(N^2) in the targetlist
length.  This is not all the trouble spots for wide queries by any
means, but it's a step forward.
16 files changed:
src/backend/nodes/bitmapset.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/pathkeys.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/util/pathnode.c
src/backend/optimizer/util/plancat.c
src/backend/optimizer/util/relnode.c
src/backend/optimizer/util/tlist.c
src/include/nodes/bitmapset.h
src/include/nodes/relation.h
src/include/optimizer/plancat.h
src/include/optimizer/planmain.h
src/include/optimizer/tlist.h