[SERVER-41458] $natural hint overrides index filters Created: 03/Jun/19  Updated: 27/Oct/23  Resolved: 24/Jul/23

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mikhail Ivkov (Inactive) Assignee: Denis Grebennicov
Resolution: Works as Designed Votes: 0
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-40810 Optimized $group/DISTINCT_SCAN does n... Closed
is related to SERVER-62985 Change query planner to generate colu... Closed
is related to SERVER-79233 Ensure query settings $natural hints ... Closed
Assigned Teams:
Query Optimization
Operating System: ALL
Sprint: QE 2023-07-24, QE 2023-08-07
Participants:

 Description   

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".


Generated at Thu Feb 08 04:57:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.