Allow queries with $expr/$in to use indexes.

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This query:

      find({$expr: { $in: ["$_id", [1, 2]]}})
      

      ... doesn't use an index.

      If I expand the $in to $or and $eq, though, it uses the index:

      find({$expr: { $or: [{$eq: ["$_id", 1]}, {$eq: ["$_id", 2]}]}})
      

      This seems like something the server could gainfully do internally to avoid a collection scan.

              Assignee:
              Unassigned
              Reporter:
              Felipe Gasper
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: