Skip to content

Commit 70fba70

Browse files
committed
Upgrade cost estimation for joins, per discussion with Bradley Baetz.
Try to model the effect of rescanning input tuples in mergejoins; account for JOIN_IN short-circuiting where appropriate. Also, recognize that mergejoin and hashjoin clauses may now be more than single operator calls, so we have to charge appropriate execution costs.
1 parent b2773d4 commit 70fba70

File tree

10 files changed

+358
-187
lines changed

10 files changed

+358
-187
lines changed

src/backend/executor/nodeHashjoin.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.47 2003/01/20 18:54:45 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.48 2003/01/27 20:51:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -253,6 +253,13 @@ ExecHashJoin(HashJoinState *node)
253253
return result;
254254
}
255255
}
256+
257+
/* If we didn't return a tuple, may need to set NeedNewOuter */
258+
if (node->js.jointype == JOIN_IN)
259+
{
260+
node->hj_NeedNewOuter = true;
261+
break; /* out of loop over hash bucket */
262+
}
256263
}
257264
}
258265

src/backend/executor/nodeNestloop.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.30 2003/01/20 18:54:46 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.31 2003/01/27 20:51:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -254,6 +254,10 @@ ExecNestLoop(NestLoopState *node)
254254
return result;
255255
}
256256
}
257+
258+
/* If we didn't return a tuple, may need to set NeedNewOuter */
259+
if (node->js.jointype == JOIN_IN)
260+
node->nl_NeedNewOuter = true;
257261
}
258262

259263
/*

src/backend/nodes/list.c

+23-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.45 2003/01/24 03:58:34 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.46 2003/01/27 20:51:49 tgl Exp $
1212
*
1313
* NOTES
1414
* XXX a few of the following functions are duplicated to handle
@@ -639,6 +639,28 @@ set_differencei(List *l1, List *l2)
639639
return result;
640640
}
641641

642+
/*
643+
* set_ptrDifference
644+
*
645+
* Same as set_difference, when pointer-equality comparison is sufficient
646+
*/
647+
List *
648+
set_ptrDifference(List *l1, List *l2)
649+
{
650+
List *result = NIL;
651+
List *i;
652+
653+
if (l2 == NIL)
654+
return listCopy(l1); /* slightly faster path for empty l2 */
655+
656+
foreach(i, l1)
657+
{
658+
if (!ptrMember(lfirst(i), l2))
659+
result = lappend(result, lfirst(i));
660+
}
661+
return result;
662+
}
663+
642664
/*
643665
* Reverse a list, non-destructively
644666
*/

0 commit comments

Comments
 (0)