mirror of https://gitee.com/bigwinds/arangodb
Cost estimates: IndexRangeNodes without range have to be more expensive than ones with.
This commit is contained in:
parent
4b41b449f5
commit
02207d5f70
|
@ -638,6 +638,7 @@ double IndexRangeNode::estimateCost () {
|
||||||
_dependencies.at(0)->getCost();
|
_dependencies.at(0)->getCost();
|
||||||
|
|
||||||
double cost = 1;
|
double cost = 1;
|
||||||
|
size_t count = 0;
|
||||||
|
|
||||||
if (_index->_type == TRI_IDX_TYPE_HASH_INDEX) {
|
if (_index->_type == TRI_IDX_TYPE_HASH_INDEX) {
|
||||||
return oldCost / 1000;
|
return oldCost / 1000;
|
||||||
|
@ -648,17 +649,24 @@ double IndexRangeNode::estimateCost () {
|
||||||
if (x.is1ValueRangeInfo()) {
|
if (x.is1ValueRangeInfo()) {
|
||||||
if (!_index->_unique) {
|
if (!_index->_unique) {
|
||||||
cost *= oldCost / 100;
|
cost *= oldCost / 100;
|
||||||
|
count ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cost *= oldCost / 10;
|
cost *= oldCost / 10;
|
||||||
|
count ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!(x._low._undefined && x._high._undefined)){
|
else if (!(x._low._undefined && x._high._undefined)){
|
||||||
cost *= oldCost / 2;
|
cost *= oldCost / 2;
|
||||||
|
count ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (count == 0) {
|
||||||
|
// no ranges? so this is unlimited -> has to be more expensive
|
||||||
|
cost *= oldCost;
|
||||||
|
}
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,13 +70,13 @@ int triagens::aql::removeRedundantSorts (Optimizer* opt,
|
||||||
auto other = static_cast<SortNode*>(current)->getSortInformation(plan);
|
auto other = static_cast<SortNode*>(current)->getSortInformation(plan);
|
||||||
|
|
||||||
switch (sortInfo.isCoveredBy(other)) {
|
switch (sortInfo.isCoveredBy(other)) {
|
||||||
case triagens::aql::SortInformation::unequal:
|
case SortInformation::unequal:
|
||||||
break;
|
break;
|
||||||
case triagens::aql::SortInformation::otherSupersedes:
|
case SortInformation::otherSupersedes:
|
||||||
toUnlink.insert(current);
|
toUnlink.insert(current);
|
||||||
break;
|
break;
|
||||||
case triagens::aql::SortInformation::weSupersede:
|
case SortInformation::weSupersede:
|
||||||
case triagens::aql::SortInformation::allEqual:
|
case SortInformation::allEqual:
|
||||||
// the sort at the start of the pipeline makes the sort at the end
|
// the sort at the start of the pipeline makes the sort at the end
|
||||||
// superfluous, so we'll remove it
|
// superfluous, so we'll remove it
|
||||||
toUnlink.insert(n);
|
toUnlink.insert(n);
|
||||||
|
|
Loading…
Reference in New Issue