Fix an oversight in the 8.2 patch that improved mergejoin performance by
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 5 Sep 2008 21:07:29 +0000 (21:07 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 5 Sep 2008 21:07:29 +0000 (21:07 +0000)
commit2488aa7b5ece7d14b4d59a0f60bbd1226a9016d9
treef6d0a5bfa9df7bb74bb53b103ef17687c7f06582
parent6934a1fe62e6dd076e5a1684dbf7f2d3fd21d43a
Fix an oversight in the 8.2 patch that improved mergejoin performance by
inserting a materialize node above an inner-side sort node, when the sort is
expected to spill to disk.  (The materialize protects the sort from having
to support mark/restore, allowing it to do its final merge pass on-the-fly.)
We neglected to teach cost_mergejoin about that hack, so it was failing to
include the materialize's costs in the estimated cost of the mergejoin.
The materialize's costs are generally going to be pretty negligible in
comparison to the sort's, so this is only a small error and probably not
worth back-patching; but it's still wrong.

In the similar case where a materialize is inserted to protect an inner-side
node that can't do mark/restore at all, it's still true that the materialize
should not spill to disk, and so we should cost it cheaply rather than
expensively.

Noted while thinking about a question from Tom Raney.
src/backend/optimizer/path/costsize.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/util/pathnode.c