This is an automated email from the ASF dual-hosted git repository.
vsarathy1 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
The following commit(s) were added to refs/heads/master by this push:
new c052f9adfa [ASTERIXDB-3454][COMP] Make Array Indexes more expensive
c052f9adfa is described below
commit c052f9adfa8619626455ec5e203dfaf21270d235
Author: murali4104 <[email protected]>
AuthorDate: Tue Jul 16 13:51:30 2024 -0700
[ASTERIXDB-3454][COMP] Make Array Indexes more expensive
Change-Id: I5fb553ebcb9219b14c77aec19889529ccb34c587
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18489
Integration-Tests: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
Reviewed-by: Vijay Sarathy <[email protected]>
---
.../apache/asterix/optimizer/rules/cbo/JoinNode.java | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinNode.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinNode.java
index 9fb0e72ba6..b946ba8cdc 100644
---
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinNode.java
+++
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinNode.java
@@ -643,12 +643,18 @@ public class JoinNode {
List<Triple<Index, Double, AbstractFunctionCallExpression>>
mandatoryIndexesInfo = new ArrayList<>();
List<Triple<Index, Double, AbstractFunctionCallExpression>>
optionalIndexesInfo = new ArrayList<>();
double sel = 1.0;
+ boolean mandatoryArrayIndexUsed = false;
+ boolean optionalArrayIndexUsed = false;
opCost = this.joinEnum.getCostHandle().zeroCost();
for (int i = 0; i < IndexCostInfo.size(); i++) {
if (joinEnum.findUseIndexHint(IndexCostInfo.get(i).third)) {
mandatoryIndexesInfo.add(IndexCostInfo.get(i));
+ mandatoryArrayIndexUsed = mandatoryArrayIndexUsed
+ || (mandatoryIndexesInfo.get(i).first.getIndexType()
== DatasetConfig.IndexType.ARRAY);
} else {
optionalIndexesInfo.add(IndexCostInfo.get(i));
+ optionalArrayIndexUsed = optionalArrayIndexUsed
+ || (optionalIndexesInfo.get(i).first.getIndexType() ==
DatasetConfig.IndexType.ARRAY);
}
}
@@ -669,11 +675,13 @@ public class JoinNode {
// Now add the data Scan cost.
ICost dataScanCost =
joinEnum.getCostMethodsHandle().costIndexDataScan(this, sel);
opCost = opCost.costAdd(dataScanCost); // opCost now has the total
cost of all the mandatory indexes + data costs.
-
+ if (mandatoryArrayIndexUsed) {
+ opCost = opCost.costAdd(opCost);
+ }
}
ICost mandatoryIndexesCost = opCost; // This will be added at the end
to the total cost irrespective of optimality.
-
+ //opCost = this.joinEnum.getCostHandle().zeroCost(); // compute cost
for optional indexes and store in opCost.
// Now lets deal with the optional indexes. These are the ones without
any hints on them.
List<ICost> dataCosts = new ArrayList<>(); // these are the costs
associated with accessing the data records
indexCosts.clear();
@@ -721,6 +729,9 @@ public class JoinNode {
break; // can't get any cheaper.
}
}
+ if (optionalArrayIndexUsed) {
+ opCost = opCost.costAdd(opCost);
+ }
}
// opCost is now the total cost of the indexes chosen along with the
associated data scan cost.
@@ -731,6 +742,8 @@ public class JoinNode {
}
totalCost = opCost.costAdd(mandatoryIndexesCost); // cost of all the
indexes chosen
+ // Now check if any of the indexes were array indexes. If so double
the cost
+
boolean forceEnum = mandatoryIndexesInfo.size() > 0 || level <=
joinEnum.cboFullEnumLevel;
if (opCost.costLT(this.cheapestPlanCost) || forceEnum) {
pn = new PlanNode(allPlans.size(), joinEnum, this,
datasetNames.get(0), leafInput);