[SERVER-7742] Improve the way indexes are used to do a range query on one field and sort on another Created: 21/Nov/12 Updated: 23/Sep/13 Resolved: 23/Sep/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Spencer Brody (Inactive) | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Operating System: | ALL | ||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
The "Equality, Range Query, And Sort" section of Jesse's blog post here describes how if you do a range query on one field and sort on another you have to choose between lowering your nscanned or getting rid of the in-memory sort. If you put the sort key first, you get rid of the in-memory sort, but at the cost of higher nscanned. If you put the sort key last, however, you can get nscanned down to exactly n, but you'll have to do an in-memory sort. |