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

Query optimizer should efficiently handle $in and sort with compound index.

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.5
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:

      Suppose you have an index on

      {friend_id: 1, date: -1}

      Then, suppose you have a query like this:

      db.things.find({ friend_id: {$in: [lots_of_ids]}}).sort(

      {date: -1}

      ).limit(20)

      Currently, this does a scanAndOrder and scans quite a few documents. Can we optimize?

            Votes:
            51 Vote for this issue
            Watchers:
            59 Start watching this issue

              Created:
              Updated:
              Resolved: