From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Support RIGHT and FULL OUTER JOIN in hash joins. |
Date: | 2010-12-31 01:26:31 |
Message-ID: | E1PYTlH-0005Hx-8J@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Support RIGHT and FULL OUTER JOIN in hash joins.
This is advantageous first because it allows us to hash the smaller table
regardless of the outer-join type, and second because hash join can be more
flexible than merge join in dealing with arbitrary join quals in a FULL
join. For merge join all the join quals have to be mergejoinable, but hash
join will work so long as there's at least one hashjoinable qual --- the
others can be any condition. (This is true essentially because we don't
keep per-inner-tuple match flags in merge join, while hash join can do so.)
To do this, we need a has-it-been-matched flag for each tuple in the
hashtable, not just one for the current outer tuple. The key idea that
makes this practical is that we can store the match flag in the tuple's
infomask, since there are lots of bits there that are of no interest for a
MinimalTuple. So we aren't increasing the size of the hashtable at all for
the feature.
To write this without turning the hash code into even more of a pile of
spaghetti than it already was, I rewrote ExecHashJoin in a state-machine
style, similar to ExecMergeJoin. Other than that decision, it was pretty
straightforward.
Branch
------
master
Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=f4e4b3274317d9ce30de7e7e5b04dece7c4e1791
Modified Files
--------------
src/backend/executor/nodeHash.c | 151 ++++++++-
src/backend/executor/nodeHashjoin.c | 576 ++++++++++++++++++-------------
src/backend/optimizer/path/equivclass.c | 7 +-
src/backend/optimizer/path/joinpath.c | 145 +++-----
src/backend/optimizer/path/joinrels.c | 12 +
src/backend/optimizer/plan/initsplan.c | 10 +-
src/include/access/htup.h | 23 ++
src/include/executor/hashjoin.h | 2 +
src/include/executor/nodeHash.h | 10 +-
src/include/nodes/execnodes.h | 23 +-
10 files changed, 596 insertions(+), 363 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2010-12-31 02:02:01 | Re: pgsql: Support RIGHT and FULL OUTER JOIN in hash joins. |
Previous Message | Peter Eisentraut | 2010-12-30 20:16:15 | pgsql: Remove tabs in SGML |