Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-55295

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

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 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

      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@mongodb.com Alice Doherty
            Reporter:
            nicholas.zolnierz@mongodb.com Nicholas Zolnierz
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: