diff options
-rw-r--r-- | src/mongo/db/explain.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/explain.h | 1 | ||||
-rw-r--r-- | src/mongo/db/ops/query.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/queryoptimizer.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/queryoptimizer.h | 1 | ||||
-rw-r--r-- | src/mongo/db/queryoptimizercursorimpl.cpp | 20 |
6 files changed, 13 insertions, 14 deletions
diff --git a/src/mongo/db/explain.cpp b/src/mongo/db/explain.cpp index 2b068d5fde8..90760fdf3a5 100644 --- a/src/mongo/db/explain.cpp +++ b/src/mongo/db/explain.cpp @@ -112,7 +112,6 @@ namespace mongo { BSONObj ExplainClauseInfo::bson() const { BSONObjBuilder bb; bb.appendElements( virtualPickedPlan().pickedPlanBson( *this ) ); - // TODO won't include plans w/ no cursor iterates. BSONArrayBuilder allPlans( bb.subarrayStart( "allPlans" ) ); for( list<shared_ptr<const ExplainPlanInfo> >::const_iterator i = _plans.begin(); i != _plans.end(); ++i ) { @@ -185,7 +184,7 @@ namespace mongo { } } verify( 16076, false ); - return *(new ExplainPlanInfo()); // TODO better + return *(new ExplainPlanInfo()); } void ExplainQueryInfo::noteIterate( bool match, bool loadedObject, bool chunkSkip ) { diff --git a/src/mongo/db/explain.h b/src/mongo/db/explain.h index 380e712dde1..b874aa7965d 100644 --- a/src/mongo/db/explain.h +++ b/src/mongo/db/explain.h @@ -57,7 +57,6 @@ namespace mongo { bool picked() const { return _picked; } bool done() const { return _done; } long long n() const { return _n; } - long long nscannedObjects() const { return _nscannedObjects; } long long nscanned() const { return _nscanned; } private: diff --git a/src/mongo/db/ops/query.cpp b/src/mongo/db/ops/query.cpp index 1c415d3bcd1..27a7d3ac019 100644 --- a/src/mongo/db/ops/query.cpp +++ b/src/mongo/db/ops/query.cpp @@ -774,6 +774,7 @@ namespace mongo { --_skip; return false; } + // Explain does not obey soft limits, so matches should not be buffered if enabled. if ( !_parsedQuery.isExplain() ) { fillQueryResultFromObj( _buf, _parsedQuery.getFields(), current( true ), ( _parsedQuery.showDiskLoc() ? &loc : 0 ) ); diff --git a/src/mongo/db/queryoptimizer.cpp b/src/mongo/db/queryoptimizer.cpp index d6750732fcf..657c7c4b6e2 100644 --- a/src/mongo/db/queryoptimizer.cpp +++ b/src/mongo/db/queryoptimizer.cpp @@ -1156,7 +1156,6 @@ doneCheckOrder: } const QueryPlan *MultiPlanScanner::singlePlan() const { -// log() << "_or: " << _or << endl; if ( _or || _currentQps->nPlans() != 1 || _currentQps->usingCachedPlan() ) { diff --git a/src/mongo/db/queryoptimizer.h b/src/mongo/db/queryoptimizer.h index de573096e9a..1df2d18b468 100644 --- a/src/mongo/db/queryoptimizer.h +++ b/src/mongo/db/queryoptimizer.h @@ -426,7 +426,6 @@ namespace mongo { bool _mayYield; ElapsedTracker _yieldSometimesTracker; bool _mustAssertOnYieldFailure; - shared_ptr<ExplainClauseInfo> _explainClauseInfo; }; /** Handles $or type queries by generating a QueryPlanSet for each $or clause. */ diff --git a/src/mongo/db/queryoptimizercursorimpl.cpp b/src/mongo/db/queryoptimizercursorimpl.cpp index 304710b2528..c8aed84f47e 100644 --- a/src/mongo/db/queryoptimizercursorimpl.cpp +++ b/src/mongo/db/queryoptimizercursorimpl.cpp @@ -295,7 +295,10 @@ namespace mongo { */ class QueryOptimizerCursorImpl : public QueryOptimizerCursor { public: - QueryOptimizerCursorImpl( auto_ptr<MultiPlanScanner> &mps, const QueryPlanSelectionPolicy &planPolicy, bool requireOrder ) : + QueryOptimizerCursorImpl( auto_ptr<MultiPlanScanner> &mps, + const QueryPlanSelectionPolicy &planPolicy, + bool requireOrder, + bool explain ) : _requireOrder( requireOrder ), _mps( mps ), _initialCandidatePlans( _mps->possibleInOrderPlan(), _mps->possibleOutOfOrderPlan() ), @@ -305,7 +308,9 @@ namespace mongo { _completePlanOfHybridSetScanAndOrderRequired(), _nscanned() { _mps->initialOp( _originalOp ); - _explainQueryInfo = _mps->generateExplainInfo(); + if ( explain ) { + _explainQueryInfo = _mps->generateExplainInfo(); + } shared_ptr<QueryOp> op = _mps->nextOp(); rethrowOnError( op ); if ( !op->complete() ) { @@ -641,10 +646,10 @@ namespace mongo { shared_ptr<Cursor> newQueryOptimizerCursor( auto_ptr<MultiPlanScanner> mps, const QueryPlanSelectionPolicy &planPolicy, - bool requireOrder ) { + bool requireOrder, bool explain ) { try { return shared_ptr<Cursor>( new QueryOptimizerCursorImpl( mps, planPolicy, - requireOrder ) ); + requireOrder, explain ) ); } catch( const AssertionException &e ) { if ( e.getCode() == OutOfOrderDocumentsAssertionCode ) { // If no indexes follow the requested sort order, return an @@ -789,10 +794,7 @@ namespace mongo { return cursor; } - if ( explain() ) { - _mps->generateExplainInfo(); - } - return newQueryOptimizerCursor( _mps, _planPolicy, requireOrder() ); + return newQueryOptimizerCursor( _mps, _planPolicy, requireOrder(), explain() ); } /** This interface is just available for testing. */ @@ -801,7 +803,7 @@ namespace mongo { const BSONObj &order, const QueryPlanSelectionPolicy &planPolicy, bool requireOrder ) { auto_ptr<MultiPlanScanner> mps( new MultiPlanScanner( ns, query, fields, order ) ); // mayYield == false - return newQueryOptimizerCursor( mps, planPolicy, requireOrder ); + return newQueryOptimizerCursor( mps, planPolicy, requireOrder, false ); } } // namespace mongo; |