[ASTERIX-3408][COMP] Added a simple check for EQ joins in findJoinSelectivity
Change-Id: Ie6acb3e0b96597106af2b71244a0dd3c07653fcc
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18328
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Vijay Sarathy <vijay.sarathy@couchbase.com>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java
index 574e207..4a57a00 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java
@@ -118,6 +118,9 @@
// Since there is a left and right dataset here, expecting only two variables.
return 1.0;
}
+ if (!(joinExpr.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.EQ))) {
+ return 0.5; // we will assume half; rest of the code assumes EQ joins
+ }
int idx1, idx2;
if (joinEnum.varLeafInputIds.containsKey(exprUsedVars.get(0))) {
idx1 = joinEnum.varLeafInputIds.get(exprUsedVars.get(0));
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/split-materialization.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/split-materialization.plan
index 3235136..104e755 100644
--- a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/split-materialization.plan
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/split-materialization.plan
@@ -5,27 +5,16 @@
-- SORT_MERGE_EXCHANGE [$$97(ASC), $$98(ASC) ] |PARTITIONED|
-- STABLE_SORT [$$97(ASC), $$98(ASC)] |PARTITIONED|
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- NESTED_LOOP |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- STREAM_PROJECT |PARTITIONED|
- -- ASSIGN |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- REPLICATE |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- STREAM_PROJECT |PARTITIONED|
- -- STREAM_SELECT |PARTITIONED|
- -- ASSIGN |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- DATASOURCE_SCAN (TinySocial.FacebookUsers) |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- EMPTY_TUPLE_SOURCE |PARTITIONED|
- -- BROADCAST_EXCHANGE |PARTITIONED|
- -- REPLICATE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- STREAM_PROJECT |PARTITIONED|
- -- STREAM_SELECT |PARTITIONED|
- -- ASSIGN |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- DATASOURCE_SCAN (TinySocial.FacebookUsers) |PARTITIONED|
+ -- BTREE_SEARCH (TinySocial.FacebookUsers.FacebookUsers) |PARTITIONED|
+ -- BROADCAST_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ -- DATASOURCE_SCAN (TinySocial.FacebookUsers) |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/split-materialization_ps.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/split-materialization_ps.plan
index cd7f5d9..0fdad7d 100644
--- a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/split-materialization_ps.plan
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/split-materialization_ps.plan
@@ -9,30 +9,19 @@
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
-- REPLICATE |PARTITIONED|
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- NESTED_LOOP |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- STREAM_PROJECT |PARTITIONED|
- -- ASSIGN |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- REPLICATE |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- STREAM_PROJECT |PARTITIONED|
- -- STREAM_SELECT |PARTITIONED|
- -- ASSIGN |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- DATASOURCE_SCAN (TinySocial.FacebookUsers) |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- EMPTY_TUPLE_SOURCE |PARTITIONED|
- -- BROADCAST_EXCHANGE |PARTITIONED|
- -- REPLICATE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- STREAM_PROJECT |PARTITIONED|
- -- STREAM_SELECT |PARTITIONED|
- -- ASSIGN |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- DATASOURCE_SCAN (TinySocial.FacebookUsers) |PARTITIONED|
+ -- BTREE_SEARCH (TinySocial.FacebookUsers.FacebookUsers) |PARTITIONED|
+ -- BROADCAST_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ -- DATASOURCE_SCAN (TinySocial.FacebookUsers) |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
-- BROADCAST_EXCHANGE |PARTITIONED|
-- AGGREGATE |UNPARTITIONED|
-- RANDOM_MERGE_EXCHANGE |PARTITIONED|
@@ -41,27 +30,16 @@
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
-- REPLICATE |PARTITIONED|
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- NESTED_LOOP |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- STREAM_PROJECT |PARTITIONED|
- -- ASSIGN |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- REPLICATE |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- STREAM_PROJECT |PARTITIONED|
- -- STREAM_SELECT |PARTITIONED|
- -- ASSIGN |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- DATASOURCE_SCAN (TinySocial.FacebookUsers) |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- EMPTY_TUPLE_SOURCE |PARTITIONED|
- -- BROADCAST_EXCHANGE |PARTITIONED|
- -- REPLICATE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- STREAM_PROJECT |PARTITIONED|
- -- STREAM_SELECT |PARTITIONED|
- -- ASSIGN |PARTITIONED|
- -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- DATASOURCE_SCAN (TinySocial.FacebookUsers) |PARTITIONED|
+ -- BTREE_SEARCH (TinySocial.FacebookUsers.FacebookUsers) |PARTITIONED|
+ -- BROADCAST_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ -- DATASOURCE_SCAN (TinySocial.FacebookUsers) |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/column/filter/not-in_every/not-in_every.201.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/column/filter/not-in_every/not-in_every.201.plan
index 1d6e680..31657c9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/column/filter/not-in_every/not-in_every.201.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/column/filter/not-in_every/not-in_every.201.plan
@@ -1,16 +1,16 @@
-distribute result [$$d] [cardinality: 6.0, op-cost: 0.0, total-cost: 37.02]
+distribute result [$$d] [cardinality: 3.0, op-cost: 0.0, total-cost: 15.5]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 6.0, op-cost: 0.0, total-cost: 37.02]
+ exchange [cardinality: 3.0, op-cost: 0.0, total-cost: 15.5]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$d]) [cardinality: 6.0, op-cost: 0.0, total-cost: 37.02]
+ project ([$$d]) [cardinality: 3.0, op-cost: 0.0, total-cost: 15.5]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 6.0, op-cost: 0.0, total-cost: 37.02]
+ exchange [cardinality: 3.0, op-cost: 0.0, total-cost: 15.5]
-- SORT_MERGE_EXCHANGE [$$24(ASC) ] |PARTITIONED|
- project ([$$d, $$24]) [cardinality: 6.0, op-cost: 0.0, total-cost: 37.02]
+ project ([$$d, $$24]) [cardinality: 3.0, op-cost: 0.0, total-cost: 15.5]
-- STREAM_PROJECT |PARTITIONED|
select ($$18) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- STREAM_SELECT |PARTITIONED|
- exchange [cardinality: 6.0, op-cost: 0.0, total-cost: 37.02]
+ exchange [cardinality: 3.0, op-cost: 0.0, total-cost: 15.5]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
group by ([$$24 := $$20]) decor ([$$d]) {
aggregate [$$18] <- [empty-stream()] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
@@ -19,11 +19,11 @@
-- STREAM_SELECT |LOCAL|
nested tuple source [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- NESTED_TUPLE_SOURCE |LOCAL|
- } [cardinality: 6.0, op-cost: 15.51, total-cost: 37.02]
+ } [cardinality: 3.0, op-cost: 4.75, total-cost: 15.5]
-- PRE_CLUSTERED_GROUP_BY[$$20] |PARTITIONED|
- exchange [cardinality: 6.0, op-cost: 0.0, total-cost: 21.51]
+ exchange [cardinality: 6.0, op-cost: 0.0, total-cost: 10.75]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- order (ASC, $$20) [cardinality: 6.0, op-cost: 15.51, total-cost: 21.51]
+ order (ASC, $$20) [cardinality: 6.0, op-cost: 4.75, total-cost: 10.75]
-- STABLE_SORT [$$20(ASC)] |PARTITIONED|
exchange [cardinality: 6.0, op-cost: 0.0, total-cost: 6.0]
-- HASH_PARTITION_EXCHANGE [$$20] |PARTITIONED|
@@ -31,7 +31,7 @@
-- STREAM_PROJECT |PARTITIONED|
exchange [cardinality: 6.0, op-cost: 0.0, total-cost: 6.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- left outer join (not(if-missing-or-null(neq($$21, $#1), false))) [cardinality: 6.0, op-cost: 6.0, total-cost: 17.0]
+ left outer join (not(if-missing-or-null(neq($$21, $#1), false))) [cardinality: 3.0, op-cost: 6.0, total-cost: 17.0]
-- NESTED_LOOP |PARTITIONED|
exchange [cardinality: 6.0, op-cost: 0.0, total-cost: 6.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|