summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-12-25 02:04:09 -0500
committerEliot Horowitz <eliot@10gen.com>2010-12-25 02:04:09 -0500
commitde3564331d6bc9e8bc79b1b45880df44f73e7cc9 (patch)
tree901d5b443e6d0d7dd04fad4b6db84a6f10fa9d26 /db
parent3007bd925db455d2ea8d62f98137b39820506837 (diff)
downloadmongo-de3564331d6bc9e8bc79b1b45880df44f73e7cc9.tar.gz
fix Matcher speed with $all SERVER-2289
Diffstat (limited to 'db')
-rw-r--r--db/matcher.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/db/matcher.cpp b/db/matcher.cpp
index d9d8f686480..544ec27f1cf 100644
--- a/db/matcher.cpp
+++ b/db/matcher.cpp
@@ -568,29 +568,25 @@ namespace mongo {
if ( em.myset->size() == 0 && !em.myregex.get() )
return -1; // is this desired?
- BSONObjSetDefaultOrder actualKeys;
- IndexSpec( BSON( fieldName << 1 ) ).getKeys( obj, actualKeys );
- if ( actualKeys.size() == 0 )
- return 0;
+ BSONElementSet myValues;
+ obj.getFieldsDotted( fieldName , myValues );
for( set< BSONElement, element_lt >::const_iterator i = em.myset->begin(); i != em.myset->end(); ++i ) {
// ignore nulls
if ( i->type() == jstNULL )
continue;
- // parallel traversal would be faster worst case I guess
- BSONObjBuilder b;
- b.appendAs( *i, "" );
- if ( !actualKeys.count( b.done() ) )
+
+ if ( myValues.count( *i ) == 0 )
return -1;
- }
+ }
if ( !em.myregex.get() )
return 1;
for( vector< RegexMatcher >::const_iterator i = em.myregex->begin(); i != em.myregex->end(); ++i ) {
bool match = false;
- for( BSONObjSetDefaultOrder::const_iterator j = actualKeys.begin(); j != actualKeys.end(); ++j ) {
- if ( regexMatches( *i, j->firstElement() ) ) {
+ for( BSONElementSet::const_iterator j = myValues.begin(); j != myValues.end(); ++j ) {
+ if ( regexMatches( *i, *j ) ) {
match = true;
break;
}