[SERVER-4299] Adding .sort(...) to an $or query prevents use of indexes. Created: 16/Nov/11 Updated: 29/Feb/12 Resolved: 16/Nov/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance |
| Affects Version/s: | 2.0.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Marc Bastien | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | indexing, sort | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
This was generated from the Google Groups discussion, "sorting, does not use defined index." To reproduce: ); > db.example.find({$or:[ {a:"aaa"}, {a:"bbb"}]}).explain(true) The index is used, and "nscanned" : 2 Now sort the results: > db.example.find({$or:[ {a:"aaa"}, {a:"bbb"}]}).sort( {a:1}).explain(true) |
| Comments |
| Comment by Scott Hernandez (Inactive) [ 16/Nov/11 ] |
|
dup of |