Clean up unneeded code for $natural hint overriding $natural sort

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Query Optimization
    • Minor Change
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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() );
      

            Assignee:
            [DO NOT USE] Backlog - Query Optimization
            Reporter:
            Aaron Staple (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: