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

[CQF] Improve constant folding for And/Or with a constant RHS if LHS is guaranteed to not return Nothing

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • QO 2023-11-27, QO 2023-12-11, QO 2023-12-25, QO 2024-01-08

      Currently our constant folding implementation will ignore AND(..., false) and OR(..., true) in order to respect SBE's short circuiting semantics. This is because the LHS will evaluate to either a boolean or Nothing. In the case that the LHS evaluates to Nothing, SBE will not evaluate the RHS. That is why our constant folding cannot fold these expressions.

      Interval simplification generates expressions that look like this, but we can prove that LHS will never return nothing, since there are no field accesses on the LHS, there are only constants, getParam() invocations, or BinaryOps.

      This ticket is to improve constant folding to keep track of the Nothingness of expressions and make use of it in the case of AND/OR with a constant RHS.

            Assignee:
            lynne.wang@mongodb.com Lynne Wang
            Reporter:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: