Changeset: e44ee2f00d1c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e44ee2f00d1c
Modified Files:
sql/server/rel_optimizer.c
sql/test/SQLancer/Tests/sqlancer14.test
Branch: default
Log Message:
Making find_candidate_join2semi more restrictive. If all join expressions can
be pushed down, then it cannot be rewritten into a semijoin
diffs (112 lines):
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -5428,24 +5428,36 @@ find_projection_for_join2semi(sql_rel *r
return false;
}
-
static sql_rel *
find_candidate_join2semi(sql_rel *rel, bool *swap)
{
/* generalize possibility : we need the visitor 'step' here */
if (rel_is_ref(rel)) /* if the join has multiple references, it's
dangerous to convert it into a semijoin */
return NULL;
- if (rel->op == op_join && rel->exps) {
+ if (rel->op == op_join && !list_empty(rel->exps)) {
sql_rel *l = rel->l, *r = rel->r;
+ bool ok = false;
if (find_projection_for_join2semi(r)) {
*swap = false;
+ ok = true;
+ } else if (find_projection_for_join2semi(l)) {
+ *swap = true;
+ ok = true;
+ }
+
+ if (ok) {
+ ok = false;
+ /* if all join expressions can be pushed down, then it
cannot be rewritten into a semijoin */
+ for (node *n=rel->exps->h; n && !ok; n = n->next) {
+ sql_exp *e = n->data;
+
+ ok |= !rel_has_cmp_exp(l, e) &&
!rel_has_cmp_exp(r, e);
+ }
+ }
+
+ if (ok)
return rel;
- }
- if (find_projection_for_join2semi(l)) {
- *swap = true;
- return rel;
- }
}
if (is_join(rel->op) || is_semi(rel->op)) {
sql_rel *c;
diff --git a/sql/test/SQLancer/Tests/sqlancer14.test
b/sql/test/SQLancer/Tests/sqlancer14.test
--- a/sql/test/SQLancer/Tests/sqlancer14.test
+++ b/sql/test/SQLancer/Tests/sqlancer14.test
@@ -136,6 +136,30 @@ COPY 6 RECORDS INTO "sys"."t2" FROM stdi
query T rowsort
SELECT t1.c5 FROM t2, t1 CROSS JOIN (SELECT DISTINCT t0.c0 FROM t0) AS sub0
WHERE CASE 2 WHEN 3 THEN t2.c3 > t1.c2 ELSE TRUE END
----
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
+*zd @+~U[
2b1fb0c3-bfa0-863f-9afc-5adfbe2c007e
2b1fb0c3-bfa0-863f-9afc-5adfbe2c007e
2b1fb0c3-bfa0-863f-9afc-5adfbe2c007e
@@ -184,30 +208,6 @@ 3dcfce29-ebb2-de1f-c3b9-c2830bdffaa6
3dcfce29-ebb2-de1f-c3b9-c2830bdffaa6
3dcfce29-ebb2-de1f-c3b9-c2830bdffaa6
3dcfce29-ebb2-de1f-c3b9-c2830bdffaa6
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
-*zd \n+~U[
query T rowsort
SELECT CASE 2 WHEN 3 THEN t2.c3 > t1.c2 ELSE TRUE END FROM t2, t1 CROSS JOIN
(SELECT DISTINCT t0.c0 FROM t0) AS sub0
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list