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

Ensure $or -> $in optimization parity

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Query Optimization
    • Fully Compatible
    • QO 2022-03-07

      During pipeline optimization, we currently rewrite a $or with equality conditions on the same path into a $in. That is:

      {$or: [{a: 1}, {a: 2}]}

      becomes

      {a: {$in: [1, 2]}}.

      There is also support to rewrite part of a $or as follows:

      {$or: [{a: 1}, {a: 2}, {b: 3}]} 

      becomes

      {$or: [{a: {$in: [1, 2]}}, {b: 3}].

      The first part of the optimization (replacing an entire $or with an $in) is supported by the new optimizer in the logical rewrites phase. The second part is not yet supported by the new optimizer. Eventually, when we don't run pipeline optimization before we hit the new optimizer, we'll need to support this behavior in the new optimizer.

            Assignee:
            hana.pearlman@mongodb.com Hana Pearlman
            Reporter:
            hana.pearlman@mongodb.com Hana Pearlman
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: