diff --git a/arangod/Aql/ExecutionNode.cpp b/arangod/Aql/ExecutionNode.cpp index b6dfd4e919..5b247d7a7b 100644 --- a/arangod/Aql/ExecutionNode.cpp +++ b/arangod/Aql/ExecutionNode.cpp @@ -638,6 +638,7 @@ double IndexRangeNode::estimateCost () { _dependencies.at(0)->getCost(); double cost = 1; + size_t count = 0; if (_index->_type == TRI_IDX_TYPE_HASH_INDEX) { return oldCost / 1000; @@ -648,17 +649,24 @@ double IndexRangeNode::estimateCost () { if (x.is1ValueRangeInfo()) { if (!_index->_unique) { cost *= oldCost / 100; + count ++; } } else { cost *= oldCost / 10; + count ++; } } else if (!(x._low._undefined && x._high._undefined)){ cost *= oldCost / 2; + count ++; } } } + if (count == 0) { + // no ranges? so this is unlimited -> has to be more expensive + cost *= oldCost; + } return cost; } diff --git a/arangod/Aql/OptimizerRules.cpp b/arangod/Aql/OptimizerRules.cpp index d85e82569b..a34d21418d 100644 --- a/arangod/Aql/OptimizerRules.cpp +++ b/arangod/Aql/OptimizerRules.cpp @@ -70,13 +70,13 @@ int triagens::aql::removeRedundantSorts (Optimizer* opt, auto other = static_cast(current)->getSortInformation(plan); switch (sortInfo.isCoveredBy(other)) { - case triagens::aql::SortInformation::unequal: + case SortInformation::unequal: break; - case triagens::aql::SortInformation::otherSupersedes: + case SortInformation::otherSupersedes: toUnlink.insert(current); break; - case triagens::aql::SortInformation::weSupersede: - case triagens::aql::SortInformation::allEqual: + case SortInformation::weSupersede: + case SortInformation::allEqual: // the sort at the start of the pipeline makes the sort at the end // superfluous, so we'll remove it toUnlink.insert(n);