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

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

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.5
    • Component/s: Querying
    • Labels:

      Description

      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?

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                51 Vote for this issue
                Watchers:
                61 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: