Partial index isSubsetOf() should recognize equality predicates as subsets of $type partial filters

XMLWordPrintableJSON

    • 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 index's partialFilterExpression uses $type, the index is not considered eligible for a query with an equality predicate satisfying that type constraint.

      For example,

       

      db.c.createIndex({x: 1},
                       {partialFilterExpression: {x: {$type: "objectId"}}})
      db.c.find({x: ObjectId("...")}).explain()
      { ... "winningPlan": { "stage": "COLLSCAN", ... } } 

      This query should be eligible to use the partial index.

       

      Proposed solution:

      Add a case to isSubsetOf to handle the case of $eq implying $type.

            Assignee:
            Unassigned
            Reporter:
            Ben Shteinfeld
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: