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

SBE fillEmpty should short circuit

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Fully Compatible
    • QE 2022-10-31, QE 2022-11-14
    • 5
    • 5

      Sometimes the right-hand argument of fillEmpty is a complex expression:

      $ mongod --setParameter featureFlagSbeFull=1
      ...
      $ mongo
      > db.c.find({$expr: {$eq: ["$a", 42]}}).explain().queryPlanner.winningPlan.slotBasedPlan.stages
      ...
      fillEmpty(((l1.0 <=> l1.1) == 0), ((exists(l1.0) && typeMatch(l1.0, -65)) == (exists(l1.1) && typeMatch(l1.1, -65))))
      

      Ideally when the left argument is non-Nothing, we shouldn't evaluate the right argument.

      But currently, fillEmpty is represented as an EFunction, and all EFunctions are expected to be strict. (EFunctions cannot short circuit.) We should introduce an EPrimBinary for fillEmpty, and then compile it similarly to logicOr to jump over the compiled right-hand side.

      We can also have special cases when the rhs is EConstant or EVariable (use the existing fillEmpty and fillEmptyImm instructions) and remove the EFunction fillEmpty.

            Assignee:
            martin.neupauer@mongodb.com Martin Neupauer
            Reporter:
            david.percy@mongodb.com David Percy
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: