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

XMLWordPrintableJSON

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

      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?

              Assignee:
              hari.khalsa@10gen.com
              Reporter:
              Kyle Banker (Inactive)
              Votes:
              51 Vote for this issue
              Watchers:
              59 Start watching this issue

                Created:
                Updated:
                Resolved: