[DOCS-1111] Misleading/ambiguous statement in the index page regarding sort and query Created: 11/Feb/13 Updated: 22/Jan/14 Resolved: 29/Jul/13 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | v1.2 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Kay Kim (Inactive) | Assignee: | Kay Kim (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Days since reply: | 10 years, 29 weeks, 2 days ago | ||||||||
| Description |
|
The Indexing Strategies page (http://docs.mongodb.org/manual/applications/indexes/#use-indexes-to-sort-query-results) has the following statement: For queries that include a sort that uses a compound index, ensure that all fields before the first sorted field are equality matches. I verified with Aaron to decode the sentence as such: For queries that include a sort that uses a compound index, if the sortuses a subset of the index, such as .sort( { b: 1 } ), then to ensure So, for an index of { a: 1, b: 1, c:1, d: 1 }
db.collection.find( { a: 5 }).sort( {b:1 })
db.collection.find( { a: {$gt: 5} } ).sort( { b:1 }) As for the query you were specifically wondering about: db.collection.find( { b:5 }).sort( { a:1, b:1 }) that query uses a subset in the .sort(); however, the first index field in the sort keys is 'a' and in our index of { a: 1, b: 1, c:1, d: 1 }, there is no field |
| Comments |
| Comment by auto [ 29/Jul/13 ] |
|
Author: {u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}Message:
Signed-off-by: Sam Kleinman <samk@10gen.com> |
| Comment by auto [ 29/Jul/13 ] |
|
Author: {u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}Message:
Signed-off-by: Sam Kleinman <samk@10gen.com> |
| Comment by auto [ 29/Jul/13 ] |
|
Author: {u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}Message:
Signed-off-by: Sam Kleinman <samk@10gen.com> |