[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:
Problem/Incident
causes SERVER-58680 $ifNull behaves differently in latest Closed
Related
is related to SERVER-55297 Short circuit $cond if condition is a... Closed
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: SERVER-55295 Short circuit $ifNull expression if the condition always evaluates to a constant or null
Branch: master
https://github.com/mongodb/mongo/commit/3eb04f477ea08e9cd346a34a5d131db0d05289fb

Comment by David Percy [ 25/Mar/21 ]

This is similar to $cond: SERVER-55297

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