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

sort/limit optimization with {$in} expression isn't used if null is one of the values for $in.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 2.4.0
    • Fix Version/s: None
    • Component/s: Indexing
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL

      Description

      This looks like a partial regression of SERVER-5777

      My test:
      Index: {a:1, date:-1}
      2.2.x query:

       
      find({a:{$in:[1,2]}}).limit(5).sort({date:-1})  

      correctly limits documents (nscanned and nscannedObject to 10).

      find({a:{$in:[null,2]}}).limit(5).sort({date:-1})

      same thing.

      2.4.x query:

      find({a:{$in:[1,2]}}).limit(5).sort({date:-1})

      correctly limits to 10 docs.

      find({a:{$in:[null,2]}}).limit(5).sort({date:-1})

      scans all matching a documents without applying limit.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: