8000 prefer an index if more index attributes cover a filter condition (#6… · mnemosdev/arangodb@8f8408f · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f8408f

Browse files
authored
prefer an index if more index attributes cover a filter condition (arangodb#6901)
1 parent c7933bc commit 8f8408f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arangod/Indexes/SkiplistIndexAttributeMatcher.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ bool SkiplistIndexAttributeMatcher::supportsFilterCondition(
196196
size_t attributesCoveredByEquality = 0;
197197
double equalityReductionFactor = 20.0;
198198
estimatedCost = static_cast<double>(itemsInIndex);
199-
199+
200200
for (size_t i = 0; i < idx->fields().size(); ++i) {
201201
auto it = found.find(i);
202202

@@ -250,7 +250,7 @@ bool SkiplistIndexAttributeMatcher::supportsFilterCondition(
250250
if (values == 0) {
251251
values = 1;
252252
}
253-
253+
254254
if (attributesCoveredByEquality == idx->fields().size() &&
255255
(idx->unique() || idx->implicitlyUnique())) {
256256
// index is unique and condition covers all attributes by equality
@@ -335,7 +335,7 @@ bool SkiplistIndexAttributeMatcher::supportsFilterCondition(
335335
// lookup cost is O(log(n))
336336
estimatedCost = (std::max)(static_cast<double>(1), std::log2(static_cast<double>(itemsInIndex)) * values);
337337
// slightly prefer indexes that cover more attributes
338-
estimatedCost -= (idx->fields().size() - 1) * 0.01;
338+
estimatedCost -= (attributesCovered - 1) * 0.02;
339339
}
340340
return true;
341341
}

0 commit comments

Comments
 (0)
0