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,17 +1044,11 @@ bool RocksDBVPackIndex::supportsFilterCondition(
|
|||
|
||||
if (attributesCoveredByEquality == _fields.size() && unique()) {
|
||||
// index is unique and condition covers all attributes by equality
|
||||
if (estimatedItems >= values) {
|
||||
// reduce costs due to uniqueness
|
||||
estimatedItems = values;
|
||||
estimatedCost = static_cast<double>(estimatedItems);
|
||||
} else {
|
||||
// cost is already low... now slightly prioritize the unique index
|
||||
estimatedCost *= 0.995;
|
||||
}
|
||||
estimatedItems = values;
|
||||
estimatedCost = 0.995 * values;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (attributesCovered > 0 &&
|
||||
(!_sparse || attributesCovered == _fields.size())) {
|
||||
// if the condition contains at least one index attribute and is not
|
||||
|
@ -1064,7 +1058,16 @@ bool RocksDBVPackIndex::supportsFilterCondition(
|
|||
// sparse indexes are contained in Index::canUseConditionPart)
|
||||
estimatedItems = static_cast<size_t>((std::max)(
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue