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

$elemMatch value predicate causes queries to accidentally fall back to the classic engine

    • Fully Compatible
    • ALL
    • QE 2022-08-08, QE 2022-09-19

      When SBE was first implemented, it supported execution of $elemMatch value expressions. We still have plenty of code to handle translation of $elemMatch value to an SBE plan (see here).

      We subsequently made a change in SERVER-57854 to fallback to the classic engine when there are predicates over empty field names. This is implemented by marking the query SBE-incompatible if any path predicate with an empty path is detected. This had the unintended side effect of preventing queries involving $elemMatch value from ever executing in SBE. The reason (as noted in SERVER-59757) is that the match expression parser internally creates predicates with empty field names as part of constructing the MatchExpression tree to represent an $elemMatch value.

      This isn't technically a correctness bug, but it does leave the code base in a confusing state. The code appears to support $elemMatch value in SBE, but in fact it does not. The work for this ticket is to restore $elemMatch value support in SBE via the stage builders (or potentially delete the dead stage builder code?).

            Assignee:
            andrew.paroski@mongodb.com Drew Paroski
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: