Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-41458

$natural hint overrides index filters

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Querying
    • Operating System:
      ALL

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              misha.ivkov Mikhail Ivkov (Inactive)
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: