Changeset: e80c5e9652d6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e80c5e9652d6
Modified Files:
monetdb5/optimizer/opt_postfix.c
Branch: Jul2021
Log Message:
if the semijoins has 'max_one' property set, then the left result cannot be
removed if not used. Otherwise when the left result is not used, rewrite it
into a join
diffs (41 lines):
diff --git a/monetdb5/optimizer/opt_postfix.c b/monetdb5/optimizer/opt_postfix.c
--- a/monetdb5/optimizer/opt_postfix.c
+++ b/monetdb5/optimizer/opt_postfix.c
@@ -47,10 +47,25 @@ OPTpostfixImplementation(Client cntxt, M
int is_first_ret_not_used = getVarEolife(mb,
getArg(p, p->retc -2)) == i;
int is_second_ret_not_used = getVarEolife(mb,
getArg(p, p->retc -1)) == i;
- if ( (is_first_ret_not_used ||
is_second_ret_not_used) && getFunctionId(p) == semijoinRef) {
+ if (getFunctionId(p) == semijoinRef &&
((is_first_ret_not_used && getVarConstant(mb, getArg(p, 7)).val.btval != 1/*not
single*/) || is_second_ret_not_used)) {
+ /* Can't swap arguments on single
semijoins */
+ if (is_first_ret_not_used) {
+ /* semijoin with just the right
output is a join */
+ getArg(p, 2) ^= getArg(p, 3);
/* swap join inputs */
+ getArg(p, 3) ^= getArg(p, 2);
+ getArg(p, 2) ^= getArg(p, 3);
+
+ getArg(p, 4) ^= getArg(p, 5);
/* swap candidate lists */
+ getArg(p, 5) ^= getArg(p, 4);
+ getArg(p, 4) ^= getArg(p, 5);
+ setFunctionId(p, joinRef);
+ delArgument(p, 7); /* delete
'max_one' argument */
+ } else {
+ /* semijoin with just the left
output is an intersection */
+ setFunctionId(p, intersectRef);
+ }
+
delArgument(p, is_second_ret_not_used ?
p->retc -1 : p->retc -2);
- /* semijoin with a single output is
called intersect */
- setFunctionId(p,intersectRef);
typeChecker(cntxt->usermodule, mb, p,
i, TRUE);
actions++;
continue;
@@ -60,7 +75,7 @@ OPTpostfixImplementation(Client cntxt, M
actions++;
continue;
} else if (is_first_ret_not_used &&
(getFunctionId(p) == joinRef || (getFunctionId(p) == thetajoinRef &&
isVarConstant(mb, getArg(p, 6))) ||
- (getFunctionId(p) ==
crossRef && isVarConstant(mb, getArg(p, 4)) && getVarConstant(mb, getArg(p,
4)).val.btval != 1))) {
+ (getFunctionId(p) ==
crossRef && getVarConstant(mb, getArg(p, 4)).val.btval != 1/*not single*/))) {
/* Can't swap arguments on single cross
products */
/* swap join inputs */
getArg(p, 2) ^= getArg(p, 3);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list