Permalink
Browse files

SERVER-4605 don't double-query for explain results

  • Loading branch information...
1 parent 4c1d7fe commit 4a39fd4c166549ac7297e5e705ff2c974363e207 Greg Studer committed Jan 24, 2012
Showing with 9 additions and 4 deletions.
  1. +8 −4 src/mongo/client/parallel.cpp
  2. +1 −0 src/mongo/client/parallel.h
@@ -1436,10 +1436,14 @@ namespace mongo {
}
void ParallelSortClusteredCursor::_explain( map< string,list<BSONObj> >& out ) {
- for ( set<ServerAndQuery>::iterator i=_servers.begin(); i!=_servers.end(); ++i ) {
- const ServerAndQuery& sq = *i;
- list<BSONObj> & l = out[sq._server];
- l.push_back( explain( sq._server , sq._extra ) );
+
+ set<Shard> shards;
+ getQueryShards( shards );
+
+ for( set<Shard>::iterator i = shards.begin(), end = shards.end(); i != end; ++i ){
+ // TODO: Make this the shard name, not address
+ list<BSONObj>& l = out[ i->getAddress().toString() ];
+ l.push_back( getShardCursor( *i )->peekFirst().getOwned() );
}
}
@@ -351,6 +351,7 @@ namespace mongo {
void finishInit();
bool isCommand(){ return NamespaceString( _qSpec.ns() ).isCommand(); }
+ bool isExplain(){ return _qSpec.isExplain(); }
bool isVersioned(){ return _qShards.size() == 0; }
bool isSharded();

0 comments on commit 4a39fd4

Please sign in to comment.