-
Type: Task
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Query Planning
-
None
-
Query Optimization
NOTE: Refer to Array CE Range Estimation for detailed explanation.
estimateRangeQueryOnArray() was designed to estimation non-$elemMatch range conditions as described in Conjunctions and Disjunctions over Array Values. However, that does not apply to intervals from IndexScanNode. So the whole if (includeScalar) statement needs to be removed.
The reason is the difference in the semantics of intervals. In Bonsai, an interval requirement, for instance, [1, 10] from query {a: {$gte: 1, $lte: 10}} is intended to match both of following documents:
// find query: {a: {$gte: 1, $lte: 10}} {a: [0, 1, 11]} // 1, 11 statisfy {$gte: 1} and 0, 1 statisfy {$lte: 10} {a: [0, 11]} // 11 statisfies {$gte: 1} and 0 statisfies {$lte: 10}
Note that the second document does not have any element satisfying the interval [1, 10], but it is still matched because the predicates are satisfied separately. The algorithm addresses this by calculating how many elements may overlap with the interval based on their minimum and maximum values.
However, IndexBoundsBuilder would not translate such a query to interval [1, 10]. Instead, it would translate the first predicate to [1, inf.0], leaving the second predicate as a residual predicate. That problem becomes similar to $elemMatch, so we should handle them in the same way.
- is fixed by
-
SERVER-97504 Enable distinction of CE estimation algorithm for range queries on multi-key fields.
- Closed
- related to
-
SERVER-97504 Enable distinction of CE estimation algorithm for range queries on multi-key fields.
- Closed