[SERVER-6193] string constants prevent optimization of non string sensitive operators Created: 24/Jun/12  Updated: 11/Jul/16  Resolved: 02/Oct/13

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 2.5.3

Type: Improvement Priority: Major - P3
Reporter: Aaron Staple Assignee: David Storch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-6192 $and and $or expressions may not shor... Closed
Participants:

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



 Comments   
Comment by auto [ 02/Oct/13 ]

Author:

{u'username': u'dannenberg', u'name': u'Matt Dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: Merge pull request #509 from dstorch/master

SERVER-6192 SERVER-6193 js test for short-circuiting of $and and $or in $agg project phase
Branch: master
https://github.com/mongodb/mongo/commit/cc506fc6a274b57ee31dac021cdecd5aee084d08

Comment by auto [ 02/Oct/13 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-6192 SERVER-6193 js test for short-circuiting of $and and $or in agg $project phase
Branch: master
https://github.com/mongodb/mongo/commit/f5168c9ae8d1e6c1bc8b09dee72dc604a75c203d

Comment by David Storch [ 01/Oct/13 ]

cr: http://codereview.10gen.com/12313003/

Comment by Matt Dannenberg [ 30/Sep/13 ]

I think this is fixed and should be verified as part of QA-374.

Comment by Mathias Stearn [ 31/Jul/13 ]

I think all you need to do is remove all of the string special casing in ExpressionNary::optimize, but you should also check each of the Expressions that defines a getFactory() to make sure that they are associative and commutative even with string arguments.

Generated at Thu Feb 08 03:11:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.