[SERVER-4135] Sort using compound indexing Created: 24/Oct/11 Updated: 29/Feb/12 Resolved: 25/Oct/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | Wei Kong | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
if I create a compound index parent_id + name when I do a query and sort by name, does it use index to do the sort? How can I make sure that sort by name will use index if I only have a compound index? |
| Comments |
| Comment by Eliot Horowitz (Inactive) [ 25/Oct/11 ] |
|
yes, if you have an index on parent_id , name a query like find ( { parent_id : ... }).sort( { name : 1 } ) please try explain() |