multiple predicates for $all and multiKey index is order dependent

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.6.0-rc1
    • Component/s: Querying
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In 2.6.0-rc1 I have an array "attr" which is indexed. Its contents are strings. In a query of type:

      db.prod2.find({attr:{$all:["string1","string2","string3"]}})
      

      The nscanned seems to be dependent on the order of values inside the $all list. Putting the more selective string first causes nscanned to be equal to number of documents with that string present.

      Explain(true) shows only one index boundary is considered - the one that's listed first.

      Note: this does not happen if the array elements are subdocuments and $elemMatch is used - then explain(true) shows that each of the elements in the $all list are tried and the one that's most selective is chosen regardless of the order they are given in.

              Assignee:
              David Storch
              Reporter:
              Asya Kamsky
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: