-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
-
Query Execution
-
QE 2024-05-13
This code from SERVER-74264 disabled constant folding for expressions involving $$NOW, $$CLUSTER_TIME, or $$USER_ROLES. This prevents some relatively simple queries from being satisfied by an index. For example:
db.coll.find({"$expr": {"$lt": ["$_ts",
{"$subtract": ["$$NOW",604800]}]}})
will lead to a collection scan even if there is an index on the _ts field.
We should find a way to build an IXSCAN plan for such queries while still avoiding the plan cache bug fixed by SERVER-74264.
Note that this was inspired by HELP-52526 for a query generated by online archive.
- is related to
-
SERVER-87218 Improve index usage for constants inside of `let`
- Open
- related to
-
SERVER-87218 Improve index usage for constants inside of `let`
- Open