|
There are some optimizations we can make to cases where we currently limit key matching. In some cases a match is possible with a single key index while not with multikey, in some cases a match can be a keymatch based on the value being compared (for example if it is a non null value), and there are some other things we can do too.
Matcher::Matcher( const Matcher &other, const BSONObj &key ) :
where(0), constrainIndexKey_( key ), haveSize(), all(), hasArray(0), haveNeg(), _atomic(false), nRegex(0) {
// do not include field matches which would make keyMatch() false
for( vector< ElementMatcher >::const_iterator i = other.basics.begin(); i != other.basics.end(); ++i ) {
if ( key.hasField( i->toMatch.fieldName() ) ) {
switch( i->compareOp ) {
case BSONObj::opSIZE:
case BSONObj::opALL:
case BSONObj::NE:
case BSONObj::NIN:
case BSONObj::opEXISTS: // Not part of keyMatch() determination, but we can't match on index in this case.
case BSONObj::opTYPE: // For $type:10 (null), a null key could be a missing field or a null value field.
|