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

Use knowledge about partial index filter expression to determine whether $exists predicate can be covered

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

      Given documents of the form

      {
          _id: ObjectId("..."),
          a: "2016-08-07",
          ...
          b: 2222,
          c: 3333
          ...
      },
      {
          _id: ObjectId("..."),
          a: "2016-08-07"
          c: 4444,
          ...
      },
      {
          _id: ObjectId("..."),
          a: "2016-08-07",
          ...
          b: 4444,
          c: 5555
          ...
      },
      

      And a partial index of the form

      db.foo.createIndex({a: -1, b: 1}, partialFilterExpression: {b: {$exists: true}})
      

      The query planner can use this index to fully cover a query of the following form:

      db.foo.find({a: { $lte: '2016-08-11' }, b: {$exists: true}}, {_id: 0, a: 1})
      

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            peter.garafano@mongodb.com Peter Garafano (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            20 Start watching this issue

              Created:
              Updated: