Partial index isSubsetOf should support $in predicates against $in partial filters

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When a partial filter expression uses $in we sometimes don't recognize that it can satisfy a query using $in. For example:

      > db.foo.createIndex({a: 1, b: 1}, {partialFilterExpression: {b: {$in: [1, 2, 3]}}})
      > db.foo.explain().aggregate({$match: {a: 1, b: {$in: [1, 2]}}})
      {
          …
          “winningPlan" : {
              "stage" : "COLLSCAN”,
          …
      }

      This query should be eligible to use this index.

       

      The problem is in our expression_algo::isSubsetOf() logic for $in partial filter expressions  here. In particular, the loop over the elements of the RHS in-list is overly conservative. Instead, we should check if one in-list is a subset of another.

       

      This issue is similar to SERVER-73792 but proposes to target this singular, specific improvement. 

            Assignee:
            Unassigned
            Reporter:
            Hana Pearlman
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: