Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-3187

keymatch optimizations, in particular for negative predicates

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • None

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: