[SERVER-55297] Short circuit $cond if condition is a constant Created: 18/Mar/21  Updated: 29/Oct/23  Resolved: 25/Aug/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: David Percy Assignee: Alexander Ignatyev
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-55295 Short circuit $ifNull expression if t... Closed
related to SERVER-56719 Short circuit $switch when any condit... Closed
Backwards Compatibility: Fully Compatible
Sprint: QE 2021-08-09
Participants:

 Description   

ExpressionCond::evaluate() only evaluates one or the other branch, depending on the value of the condition. We should have it do the same short-circuiting during optimize(). An expression like {$cond: [true, "$a", "$b"]} can be simplified to "$a", even though "$a" and "$b" are not constants.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 10/Aug/21 ]

Author:

{'name': 'Alexander Ignatyev', 'email': 'alexander.ignatyev@mongodb.com', 'username': 'aligusnet'}

Message: SERVER-55297 Optimize ExpressionCond in case of constant condition
Branch: master
https://github.com/mongodb/mongo/commit/b90a2a93631d94fd710338ac688e035e634cfe6a

Comment by David Percy [ 25/Mar/21 ]

This is similar to $ifNull: SERVER-55295

Generated at Thu Feb 08 05:36:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.