-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Querying
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?
- depends on
-
SERVER-5063 $in on first compound key element and limit efficiency
- Closed
- duplicates
-
SERVER-959 never do a table scan to answer db.f.find( {y:10} ).sort( {x:1} ) when have index {x:1,y:1}
- Closed
- is depended on by
-
SERVER-10472 find(a).sort(b,_id) doesn't use index(a,b) to minimize scans
- Backlog
- is duplicated by
-
SERVER-2148 $in with sort doesnt use index
- Closed
-
SERVER-5032 unnecessarily large nScanned occurs during sharded $in queries with sort() and limit()
- Closed
- is related to
-
SERVER-11116 cursor limit has inconsistent effect on compound index scan count
- Closed
- related to
-
SERVER-7742 Improve the way indexes are used to do a range query on one field and sort on another
- Closed
-
SERVER-3758 push limit down into index scan for sort + limit queries
- Backlog
-
SERVER-8790 Introduce composable "stages" in query execution
- Closed