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

string constants prevent optimization of non string sensitive operators

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.3
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None

      Observed behavior: The presence of a string in a $and/$or expression prevents optimization.
      Expected behavior: Optimizations will be applied in spite of the string expressions.

              /*
                If there are any strings, we can't re-arrange anything, so stop
                now.
      
                LATER:  we could concatenate adjacent strings as a special case.
               */
              if (stringCount)
                  return intrusive_ptr<Expression>(this);
      

      Test:

      c = db.c;
      c.drop();
      
      c.save( { x:true } );
      
      // Optimized to 'false'.
      printjson( c.runCommand( 'aggregate', { pipeline:[ { $project:{ a:{ $and:[ 0, 1, '$x' ] \
      } } } ], explain:true } ) );
      // Not optimized.
      printjson( c.runCommand( 'aggregate', { pipeline:[ { $project:{ a:{ $and:[ 0, 1, '', '$x\
      ' ] } } } ], explain:true } ) );
      

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: