OSDN Git Service

Performance fix for new anti-join code in nodeMergejoin.c: after finding a
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 15 Aug 2008 19:20:42 +0000 (19:20 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 15 Aug 2008 19:20:42 +0000 (19:20 +0000)
commit118461114e14f4fac5103df173df192771b5befc
tree5fa7ffade872a081f8133e119c7255306d6f37f1
parent5b8eb2b4b95ac4b016368ce6ca2c3477387e7fc7
Performance fix for new anti-join code in nodeMergejoin.c: after finding a
match in antijoin mode, we should advance to next outer tuple not next inner.
We know we don't want to return this outer tuple, and there is no point in
advancing over matching inner tuples now, because we'd just have to do it
again if the next outer tuple has the same merge key.  This makes a noticeable
difference if there are lots of duplicate keys in both inputs.

Similarly, after finding a match in semijoin mode, arrange to advance to
the next outer tuple after returning the current match; or immediately,
if it fails the extra quals.  The rationale is the same.  (This is a
performance bug in existing releases; perhaps worth back-patching?  The
planner tries to avoid using mergejoin with lots of duplicates, so it may
not be a big issue in practice.)

Nestloop and hash got this right to start with, but I made some cosmetic
adjustments there to make the corresponding bits of logic look more similar.
src/backend/executor/nodeHashjoin.c
src/backend/executor/nodeMergejoin.c
src/backend/executor/nodeNestloop.c