mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
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.
This commit is contained in:
@@ -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/executor/execdebug.h,v 1.26 2005/03/16 21:38:09 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/executor/execdebug.h,v 1.27 2005/05/13 21:20:16 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -258,17 +258,14 @@ extern int NIndexTupleInserted;
|
||||
#define MJ2_printf(s, p1, p2) printf(s, p1, p2)
|
||||
#define MJ_debugtup(slot) debugtup(slot, NULL)
|
||||
#define MJ_dump(state) ExecMergeTupleDump(state)
|
||||
#define MJ_DEBUG_COMPARE(res) \
|
||||
MJ1_printf(" MJCompare() returns %d\n", (res))
|
||||
#define MJ_DEBUG_QUAL(clause, res) \
|
||||
MJ2_printf(" ExecQual(%s, econtext) returns %s\n", \
|
||||
CppAsString(clause), T_OR_F(res));
|
||||
|
||||
#define MJ_DEBUG_MERGE_COMPARE(qual, res) \
|
||||
MJ2_printf(" MergeCompare(mergeclauses, %s, ...) returns %s\n", \
|
||||
CppAsString(qual), T_OR_F(res));
|
||||
|
||||
CppAsString(clause), T_OR_F(res))
|
||||
#define MJ_DEBUG_PROC_NODE(slot) \
|
||||
MJ2_printf(" %s = ExecProcNode(...) returns %s\n", \
|
||||
CppAsString(slot), NULL_OR_TUPLE(slot));
|
||||
CppAsString(slot), NULL_OR_TUPLE(slot))
|
||||
|
||||
#else
|
||||
|
||||
@@ -278,8 +275,8 @@ extern int NIndexTupleInserted;
|
||||
#define MJ2_printf(s, p1, p2)
|
||||
#define MJ_debugtup(slot)
|
||||
#define MJ_dump(state)
|
||||
#define MJ_DEBUG_COMPARE(res)
|
||||
#define MJ_DEBUG_QUAL(clause, res)
|
||||
#define MJ_DEBUG_MERGE_COMPARE(qual, res)
|
||||
#define MJ_DEBUG_PROC_NODE(slot)
|
||||
#endif /* EXEC_MERGEJOINDEBUG */
|
||||
|
||||
|
Reference in New Issue
Block a user