-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
QO 2022-07-11, QO 2022-07-25, QO 2022-08-08, QO 2022-08-22, QO 2022-09-05, QO 2022-09-19
-
(copied to CRM)
Similarly to SERVER-31760 it's possible to rewrite $expr with $gt/$lt expression to an indexable MatchExpression.
I believe the two clear cases of this are:
- bounded on both ends comparison to same type, i.e. {$and:[{$gte:["$x",0]}, {$lt:["$x",100]}]} can be rewritten to {x:{$gte:0, $lt:100}
- comparison to type and'ed with $type comparison to same type, i.e. {$and:[{$lt:["$sys_created_on",ISODate("2012-02-28T03:04:49Z")]},{$eq:\\{$type:"$sys_created_on"},"date"}]}
I think the first case would be more common in "normal use" the second can be used to force the type bracketing semantics in aggregation comparisons.
- duplicates
-
SERVER-69680 allow $expr with comparison bounded by value and $type to use a non-multikey index
- In Code Review
-
SERVER-39943 Create match expressions for aggregation $gt/$gte/$lt/$lte and add to $expr rewrite
- Closed
- is duplicated by
-
SERVER-40636 $expr inside $match does not use indexes in many cases
- Closed
- is related to
-
SERVER-34687 Aggregation Index Performance
- Closed
- related to
-
SERVER-39938 aggregation $match before $lookup optimization doesn't happen when $expr: $eq is used
- Closed
-
SERVER-39943 Create match expressions for aggregation $gt/$gte/$lt/$lte and add to $expr rewrite
- Closed