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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: 3.2.10
    • Fix Version/s: Backlog
    • Component/s: Querying
    • Case:

      Description

      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})
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              peter.garafano Peter Garafano
              Participants:
              Votes:
              1 Vote for this issue
              Watchers:
              18 Start watching this issue

                Dates

                Created:
                Updated: