1
0
Fork 0
This commit is contained in:
Jan 2017-07-30 14:24:25 +02:00 committed by Frank Celler
parent beea9033d3
commit 87567c3c2a
3 changed files with 45 additions and 9 deletions

View File

@ -1,6 +1,8 @@
devel
-----
* fixed issue #2876: wrong skiplist index usage in edge collection
* fixed issue #2868: cname missing from logger-follow results in rocksdb
* fixed issue #2889: Traversal query using incorrect collection id

View File

@ -1281,6 +1281,7 @@ bool MMFilesSkiplistIndex::supportsFilterCondition(
arangodb::aql::AstNode const* node,
arangodb::aql::Variable const* reference, size_t itemsInIndex,
size_t& estimatedItems, double& estimatedCost) const {
std::unordered_map<size_t, std::vector<arangodb::aql::AstNode const*>> found;
std::unordered_set<std::string> nonNullAttributes;
size_t values = 0;
@ -1349,12 +1350,19 @@ bool MMFilesSkiplistIndex::supportsFilterCondition(
if (attributesCoveredByEquality == _fields.size() &&
(unique() || implicitlyUnique())) {
// 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);
if (itemsInIndex == 0) {
estimatedItems = 0;
estimatedCost = 0.0;
return true;
}
// cost is already low... now slightly prioritize the unique index
if (estimatedItems >= values) {
TRI_ASSERT(itemsInIndex > 0);
estimatedItems = values;
estimatedCost = (std::max)(static_cast<double>(1), std::log2(static_cast<double>(itemsInIndex)) * values);
}
// cost is already low... now slightly prioritize unique indexes
estimatedCost *= 0.995 - 0.05 * (_fields.size() - 1);
return true;
}
@ -1367,11 +1375,15 @@ bool MMFilesSkiplistIndex::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);
if (itemsInIndex == 0) {
estimatedCost = 0.0;
} else {
estimatedCost = (std::max)(static_cast<double>(1), std::log2(static_cast<double>(itemsInIndex)) * values);
}
return true;
}
// no condition
// index does not help for this condition
estimatedItems = itemsInIndex;
estimatedCost = static_cast<double>(estimatedItems);
return false;

View File

@ -977,8 +977,22 @@ bool RocksDBVPackIndex::supportsFilterCondition(
if (attributesCoveredByEquality == _fields.size() && unique()) {
// index is unique and condition covers all attributes by equality
if (itemsInIndex == 0) {
estimatedItems = 0;
estimatedCost = 0.0;
return true;
}
estimatedItems = values;
estimatedCost = 0.995 * values;
if (values > 0) {
if (useCache()) {
estimatedCost = static_cast<double>(estimatedItems * values);
} else {
estimatedCost = (std::max)(static_cast<double>(1), std::log2(static_cast<double>(itemsInIndex)) * values);
}
}
// cost is already low... now slightly prioritize unique indexes
estimatedCost *= 0.995 - 0.05 * (_fields.size() - 1);
return true;
}
@ -1000,11 +1014,19 @@ bool RocksDBVPackIndex::supportsFilterCondition(
estimatedItems = static_cast<size_t>(1.0 / estimate);
}
}
estimatedCost = static_cast<double>(estimatedItems);
if (itemsInIndex == 0) {
estimatedCost = 0.0;
} else {
if (useCache()) {
estimatedCost = static_cast<double>(estimatedItems * values);
} else {
estimatedCost = (std::max)(static_cast<double>(1), std::log2(static_cast<double>(itemsInIndex)) * values);
}
}
return true;
}
// no condition
// index does not help for this condition
estimatedItems = itemsInIndex;
estimatedCost = static_cast<double>(estimatedItems);
return false;