-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
Query
Count over covered index happens too slow if $in condition exists. Example:
db.forum.topics.count({ "section": ObjectId("56b25ca88d4b465a5dda716e"), "st": { "$in": [ 1, 2] } })
takes ~50ms with 20000 keys examined, while separate queries takes 1 & 0 ms:
db.forum.topics.count({ "section": ObjectId("56b25ca88d4b465a5dda716e"), "st": 1 })
db.forum.topics.count({ "section": ObjectId("56b25ca88d4b465a5dda716e"), "st": 2 })
Not we split such $in queries to mutiple, but:
1. That's not convenient
2. That's impossible for "pagination" requests, when you have $in and skip+limit.
- duplicates
-
SERVER-17266 count command performance optimization should support more complex queries
- Backlog