Details
-
Improvement
-
Resolution: Done
-
Major - P3
-
None
-
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
Issue Links
- related to
-
SERVER-6192 $and and $or expressions may not short circuit non constants and optimize to a constant if the original expression has only one constant
-
- Closed
-