[SERVER-55295] Short circuit $ifNull expression if the condition always evaluates to a constant or null Created: 18/Mar/21 Updated: 29/Oct/23 Resolved: 05/Jul/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: | Nicholas Zolnierz | Assignee: | Alice Doherty |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||
| Sprint: | Query Optimization 2021-06-28, Query Optimization 2021-07-12 | ||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
The evaluate() method of ExpressionIfNull short circuits when it finds the first non-nullish value. So an expression like {$ifNull: [null, "$a"]} could be optimized to "$a". Currently it doesn't override optimize(). It inherits some optimizations from ExpressionNary, but short circuiting is not one of them. |
| 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 [ 30/Jun/21 ] |
|
Author: {'name': 'Alice Doherty', 'email': 'alice.doherty@mongodb.com', 'username': 'alicedoherty'}Message: |
| Comment by David Percy [ 25/Mar/21 ] |
|
This is similar to $cond: |