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

string constants prevent optimization of non string sensitive operators

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.5.3
    • None
    • Aggregation Framework
    • None

    Description

      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 } ) );

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: