Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-8564

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

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 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() );
      

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: