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

Inefficient Index Scans for $or Queries Using Partial Indices

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 8.0.8
    • Component/s: None
    • ALL
    • Hide
      db.a.drop();
      db.a.createIndex(  { b: 1, c: 1 },  { partialFilterExpression: { b: { $exists: true } } });
      db.a.createIndex(  { a: 1, c: 1 },  { partialFilterExpression: { a: { $exists: true } } });
      db.a.explain().find({  $or: [    { a: 0 },    { b: 0 },  ],  c: 1,}); 

      Produces two index scans, one restricted only on the `a` field, the other only on the `b` field. The `c` field is not restricted, even though it can be.

      Show
      db.a.drop(); db.a.createIndex( { b: 1, c: 1 }, { partialFilterExpression: { b: { $exists: true } } }); db.a.createIndex( { a: 1, c: 1 }, { partialFilterExpression: { a: { $exists: true } } }); db.a.explain().find({ $or: [ { a: 0 }, { b: 0 }, ], c: 1,}); Produces two index scans, one restricted only on the `a` field, the other only on the `b` field. The `c` field is not restricted, even though it can be.
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      $or queries using partial indices produce inefficient index scans.

            Assignee:
            Unassigned Unassigned
            Reporter:
            kartalkaan.bozdogan@ocell.io Kartal Kaan Bozdoğan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: