Short circuit $ifNull expression if the condition always evaluates to a constant or null

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • Query Optimization 2021-06-28, Query Optimization 2021-07-12
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

              Assignee:
              Alice Doherty
              Reporter:
              Nicholas Zolnierz
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: