Teach tuplestore.c to throw away data before the "mark" point when the caller
Tom Lane <tgl@sss.pgh.pa.us>
Teach tuplestore.c to throw away data before the "mark" point when the caller is using mark/restore but not rewind or backward-scan capability. Insert a materialize plan node between a mergejoin and its inner child if the inner child is a sort that is expected to spill to disk. The materialize shields the sort from the need to do mark/restore and thereby allows it to perform its final merge pass on-the-fly; while the materialize itself is normally cheap since it won't spill to disk unless the number of tuples with equal key values exceeds work_mem. Greg Stark, with some kibitzing from Tom Lane.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/executor/nodeMaterial.c | modified | +21 −15 |
| src/backend/executor/nodeMergejoin.c | modified | +37 −1 |
| src/backend/optimizer/path/costsize.c | modified | +18 −1 |
| src/backend/optimizer/plan/createplan.c | modified | +25 −1 |
| src/backend/utils/sort/tuplestore.c | modified | +126 −17 |
| src/include/nodes/execnodes.h | modified | +4 −2 |
| src/include/optimizer/cost.h | modified | +2 −1 |
| src/include/utils/tuplestore.h | modified | +3 −2 |