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

Strengthen index pruning logic

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • Hide
      db.foo.createIndex( { subscription_id: 1, host_id: 1 });
      db.foo.createIndex({ subscription_id: 1, type: 1, version_id: 1 });
      let q = {
          "$or" : [
               { "subscription_id" : "legacy-alerts" },
               { "subscription_id" }
            ],
            "type" : "volume_504hour",
            "volume_id" : "vol-0d4946b1a0e55a485"
      };
      db.foo.find(q).explain();
      

      On 7.0 the explain above produces 4 total plans. On 8.0 there is only a single plan reported and it uses the

      { "subscription_id": 1, "host_id" : 1 }

      index. Critically the latter also reports prunedSimilarIndexes" : true.

      Show
      db.foo.createIndex( { subscription_id: 1, host_id: 1 }); db.foo.createIndex({ subscription_id: 1, type: 1, version_id: 1 }); let q = { "$or" : [ { "subscription_id" : "legacy-alerts" }, { "subscription_id" } ], "type" : "volume_504hour" , "volume_id" : "vol-0d4946b1a0e55a485" }; db.foo.find(q).explain(); On 7.0 the explain above produces 4 total plans. On 8.0 there is only a single plan reported and it uses the { "subscription_id": 1, "host_id" : 1 } index. Critically the latter also reports prunedSimilarIndexes" : true.

          Assignee:
          Unassigned Unassigned
          Reporter:
          christopher.harris@mongodb.com Chris Harris
          Votes:
          0 Vote for this issue
          Watchers:
          10 Start watching this issue

            Created:
            Updated: