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

multiple predicates for $all and multiKey index is order dependent

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.6.0-rc1
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Operating System:
      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

              Assignee:
              david.storch David Storch
              Reporter:
              asya Asya Kamsky
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: