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

multiple predicates for $all and multiKey index is order dependent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • 2.6.0-rc1
    • None
    • Querying
    • None
    • ALL

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              david.storch@mongodb.com David Storch
              asya.kamsky@mongodb.com Asya Kamsky
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: