Inefficient Index Scans for $or Queries Using Partial Indices

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: 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
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      $or queries using partial indices produce inefficient index scans.

              Assignee:
              Yuan Fang
              Reporter:
              Kartal Kaan Bozdoğan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: