-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
Query Optimization
-
Minor Change
Right now the only way to return documents in natural order is to use a collection scan cursor (not an index cursor). And, currently, if both an index hint and natural ordering are specified for a query, the hint will supersede the natural ordering spec and the results will not be returned in natural order. Instead, hinting an index that cannot be used to retrieve results in natural order should produce an error.
Test
c = db.c; c.drop(); c.ensureIndex( { a:1 } ); c.save( { a:2 } ); c.save( { a:1 } ); printjson( c.find( { a:{ $gt:0 } } ).sort( { $natural:1 } ).hint( { a:1 } ).toArray() ); printjson( c.find( { a:{ $gt:0 } } ).sort( { $natural:1 } ).hint( { a:1 } ).explain() );
- is duplicated by
-
SERVER-8561 Query with sort ($natural:1) is reported as indexOnly when it should not be
- Closed
- related to
-
SERVER-6979 hint with { $natural:-1 } returns documents in forward order
- Closed
-
SERVER-8607 add support for natural order sorting in memory
- Closed