mirror of https://gitee.com/bigwinds/arangodb
make use of selectivity estimates in hash, skiplist and persistent indexes (#2703)
This commit is contained in:
parent
94b4a9ec4b
commit
c7c8910c7c
|
@ -1044,14 +1044,8 @@ bool RocksDBVPackIndex::supportsFilterCondition(
|
||||||
|
|
||||||
if (attributesCoveredByEquality == _fields.size() && unique()) {
|
if (attributesCoveredByEquality == _fields.size() && unique()) {
|
||||||
// index is unique and condition covers all attributes by equality
|
// index is unique and condition covers all attributes by equality
|
||||||
if (estimatedItems >= values) {
|
estimatedItems = values;
|
||||||
// reduce costs due to uniqueness
|
estimatedCost = 0.995 * values;
|
||||||
estimatedItems = values;
|
|
||||||
estimatedCost = static_cast<double>(estimatedItems);
|
|
||||||
} else {
|
|
||||||
// cost is already low... now slightly prioritize the unique index
|
|
||||||
estimatedCost *= 0.995;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1064,7 +1058,16 @@ bool RocksDBVPackIndex::supportsFilterCondition(
|
||||||
// sparse indexes are contained in Index::canUseConditionPart)
|
// sparse indexes are contained in Index::canUseConditionPart)
|
||||||
estimatedItems = static_cast<size_t>((std::max)(
|
estimatedItems = static_cast<size_t>((std::max)(
|
||||||
static_cast<size_t>(estimatedCost * values), static_cast<size_t>(1)));
|
static_cast<size_t>(estimatedCost * values), static_cast<size_t>(1)));
|
||||||
estimatedCost *= static_cast<double>(values);
|
|
||||||
|
// check if the index has a selectivity estimate ready
|
||||||
|
if (attributesCoveredByEquality == _fields.size()) {
|
||||||
|
StringRef ignore;
|
||||||
|
double estimate = this->selectivityEstimate(&ignore);
|
||||||
|
if (estimate > 0.0) {
|
||||||
|
estimatedItems = static_cast<size_t>(1.0 / estimate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
estimatedCost = static_cast<double>(estimatedItems);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue