diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-05-13 21:20:16 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-05-13 21:20:16 +0000 |
commit | 184e7a73a5b65b040d5c6413ec249a2b47f321e7 (patch) | |
tree | bcd27493e81f97ed534f0e5c6fab5e7e1f42890a /src/include/nodes/execnodes.h | |
parent | 2979334d47c17e322c4cb10ad360cc0ee713700b (diff) | |
download | postgresql-184e7a73a5b65b040d5c6413ec249a2b47f321e7.tar.gz postgresql-184e7a73a5b65b040d5c6413ec249a2b47f321e7.zip |
Revise nodeMergejoin in light of example provided by Guillaume Smet.
When one side of the join has a NULL, we don't want to uselessly try
to match it against every remaining tuple of the other side. While
at it, rewrite the comparison machinery to avoid multiple evaluations
of the left and right input expressions and to use a btree comparator
where available, instead of double operator calls. Also revise the
state machine to eliminate redundant comparisons and hopefully make it
more readable too.
Diffstat (limited to 'src/include/nodes/execnodes.h')
-rw-r--r-- | src/include/nodes/execnodes.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 2d74d25a361..9d47c17ad23 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.131 2005/05/05 03:37:23 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.132 2005/05/13 21:20:16 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1028,24 +1028,28 @@ typedef struct NestLoopState /* ---------------- * MergeJoinState information * - * OuterSkipQual outerKey1 < innerKey1 ... - * InnerSkipQual outerKey1 > innerKey1 ... - * JoinState current "state" of join. see executor.h + * NumClauses number of mergejoinable join clauses + * Clauses info for each mergejoinable clause + * JoinState current "state" of join. see execdefs.h * MatchedOuter true if found a join match for current outer tuple * MatchedInner true if found a join match for current inner tuple - * OuterTupleSlot pointer to slot in tuple table for cur outer tuple - * InnerTupleSlot pointer to slot in tuple table for cur inner tuple - * MarkedTupleSlot pointer to slot in tuple table for marked tuple + * OuterTupleSlot slot in tuple table for cur outer tuple + * InnerTupleSlot slot in tuple table for cur inner tuple + * MarkedTupleSlot slot in tuple table for marked tuple * NullOuterTupleSlot prepared null tuple for right outer joins * NullInnerTupleSlot prepared null tuple for left outer joins + * OuterEContext workspace for computing outer tuple's join values + * InnerEContext workspace for computing inner tuple's join values * ---------------- */ +/* private in nodeMergejoin.c: */ +typedef struct MergeJoinClauseData *MergeJoinClause; + typedef struct MergeJoinState { JoinState js; /* its first field is NodeTag */ - List *mergeclauses; /* list of ExprState nodes */ - List *mj_OuterSkipQual; /* list of ExprState nodes */ - List *mj_InnerSkipQual; /* list of ExprState nodes */ + int mj_NumClauses; + MergeJoinClause mj_Clauses; /* array of length mj_NumClauses */ int mj_JoinState; bool mj_MatchedOuter; bool mj_MatchedInner; @@ -1054,6 +1058,8 @@ typedef struct MergeJoinState TupleTableSlot *mj_MarkedTupleSlot; TupleTableSlot *mj_NullOuterTupleSlot; TupleTableSlot *mj_NullInnerTupleSlot; + ExprContext *mj_OuterEContext; + ExprContext *mj_InnerEContext; } MergeJoinState; /* ---------------- |