OSDN Git Service

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)
commite540b9724822eeacf1033e9fede2162324474e5b
tree25bba4e18948aa96bc1f8a42d95a887075abb56d
parent58829581f8287f1590889b0e59a78f9615ffa2af
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