Start using order with pattern in optimizer

This commit is contained in:
Aaron
2009-02-26 11:33:23 -05:00
parent 8ccde5ae02
commit 4eae90b0a6
4 changed files with 13 additions and 8 deletions

View File

@@ -201,11 +201,11 @@ namespace mongo {
uassert( "bad hint", false );
}
BSONObj bestIndex = indexForPattern( ns, fbs_.pattern() );
BSONObj bestIndex = indexForPattern( ns, fbs_.pattern( order_ ) );
if ( !bestIndex.isEmpty() ) {
usingPrerecordedPlan_ = true;
mayRecordPlan_ = false;
oldNScanned_ = nScannedForPattern( ns, fbs_.pattern() );
oldNScanned_ = nScannedForPattern( ns, fbs_.pattern( order_ ) );
if ( !strcmp( bestIndex.firstElement().fieldName(), "$natural" ) ) {
// Table scan plan
plans_.push_back( PlanPtr( new QueryPlan( fbs_, order_ ) ) );
@@ -262,7 +262,7 @@ namespace mongo {
// plans_.size() > 1 if addOtherPlans was called in Runner::run().
if ( res->complete() || plans_.size() > 1 )
return res;
registerIndexForPattern( fbs_.ns(), fbs_.pattern(), BSONObj(), 0 );
registerIndexForPattern( fbs_.ns(), fbs_.pattern( order_ ), BSONObj(), 0 );
init();
}
Runner r( *this, op );