summaryrefslogtreecommitdiff
path: root/db/queryutil.cpp
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@10gen.com>2012-02-02 14:52:50 -0500
committerSpencer T Brody <spencer@10gen.com>2012-02-09 19:25:00 -0500
commitdd046106ba1c8de1c1ae8f5830981e18ce3dd597 (patch)
treeee5e8c3b2519687209eba93758e87035bfaddc30 /db/queryutil.cpp
parentd77cc8d850c0e27db8684c716af28b05f7ed2de1 (diff)
downloadmongo-dd046106ba1c8de1c1ae8f5830981e18ce3dd597.tar.gz
Calculating which shard(s) to send $in queries to was taking a long time. This fix changes mongos to stop limiting the shards to send to after the first $in clause - possibly sending the query to more shards than necessary, but saving time. SERVER-4745.
Diffstat (limited to 'db/queryutil.cpp')
-rw-r--r--db/queryutil.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/db/queryutil.cpp b/db/queryutil.cpp
index ef5ae3a6fdb..47f89ada5bc 100644
--- a/db/queryutil.cpp
+++ b/db/queryutil.cpp
@@ -1021,13 +1021,13 @@ namespace mongo {
BoundBuilders builders;
builders.push_back( make_pair( shared_ptr<BSONObjBuilder>( new BSONObjBuilder() ), shared_ptr<BSONObjBuilder>( new BSONObjBuilder() ) ) );
BSONObjIterator i( keyPattern );
- bool ineq = false; // until ineq is true, we are just dealing with equality and $in bounds
+ bool equalityOnly = true; // until equalityOnly is false, we are just dealing with equality (no range or $in querys).
while( i.more() ) {
BSONElement e = i.next();
const FieldRange &fr = range( e.fieldName() );
int number = (int) e.number(); // returns 0.0 if not numeric
bool forward = ( ( number >= 0 ? 1 : -1 ) * ( direction >= 0 ? 1 : -1 ) > 0 );
- if ( !ineq ) {
+ if ( equalityOnly ) {
if ( fr.equality() ) {
for( BoundBuilders::const_iterator j = builders.begin(); j != builders.end(); ++j ) {
j->first->appendAs( fr.min(), "" );
@@ -1035,9 +1035,8 @@ namespace mongo {
}
}
else {
- if ( !fr.inQuery() ) {
- ineq = true;
- }
+ equalityOnly = false;
+
BoundBuilders newBuilders;
const vector<FieldInterval> &intervals = fr.intervals();
for( BoundBuilders::const_iterator i = builders.begin(); i != builders.end(); ++i ) {