-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
Query Optimization
-
ALL
-
QE 2023-07-24, QE 2023-08-07
According to docs: https://docs.mongodb.com/manual/core/query-plans/#index-filters, Index Filters always override hints. However, according to the code path starting here $natural hint overrides index filters.
db.c.insert({a : 1}) db.runCommand({planCacheSetFilter: "c", query: {}, indexes: [{ a : 1 }]}); db.c.aggregate({$group: {_id: "$a"}}) db.c.explain().aggregate({$group: {_id: "$a"}}) db.c.explain().aggregate([{$group: {_id: "$a"}}], {hint: {$natural: 1}})
Log Level 5 shows "Forcing a table scan due to hinted $natural".
- is related to
-
SERVER-40810 Optimized $group/DISTINCT_SCAN does not respect hint
- Closed
-
SERVER-62985 Change query planner to generate column index plans when hinted
- Closed
-
SERVER-79233 Ensure query settings $natural hints are applied for the specified queries
- Closed