query optimizer does not choose appropriate partial index when matching "expression" is in $elemMatch

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Query
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Example involves index on array of key/value structures.

      db.foo.drop();
      db.foo.insert({"a":[ {"k":"x", "v":"y"},  {"k":"z", "v":1} ] })
      db.foo.createIndex({"a.k":1, "a.v":1},{partialFilterExpression:{"a.k":{$exists:true}}})
      db.foo.explain().find({"a":{$elemMatch:{"k":"x","v":"y"}}})
      // results in collection scan
      db.foo.explain().find({"a":{$elemMatch:{"k":"x","v":"y"}},"a.k":"x"})
      // does use partial index as expected, but the redundant condition should not be necessary
      

            Assignee:
            Backlog - Query Team (Inactive)
            Reporter:
            Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: