【query plans issue】inappropriate candidate plans are generated

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.6.8
    • Component/s: Querying
    • None
    • ALL
    • Hide

      1、create index: 

      { f1:1 , f2: 1 }
      

      2、aggregate explain:

      db.data.aggregate([{
      $match: {
          f1:1,
          $or: [
              { f2: 1 },
              {
                 w: 1,
                 f2: { $ne: 1 }
              }
          ]
      }}], {
              explain: true
      });
      

       when I add more elements to $or, the number of candidate plans is growing too, and it takes more time to evaluate them. 

      Show
      1、create index:  { f1:1 , f2: 1 } 2、aggregate explain: db.data.aggregate([{ $match: { f1:1, $or: [ { f2: 1 }, { w: 1, f2: { $ne: 1 } } ] }}], { explain: true });  when I add more elements to $or, the number of candidate plans is growing too, and it takes more time to evaluate them. 
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      when we update our mongodb from 3.4 to 3.6, some query plans take much more time than 3.4. some aggregation took 10 seconds in 3.6 while 100ms in 3.4.

      explain(): "rejectedPlans" is empty in 3.4, but it contains one element in 3.6.

      I found the variable "_candidates" in "multi_plan.cpp" are inappropriate. In this case, it may take much more time to evaluate these candidate plans.

            Assignee:
            Danny Hatcher (Inactive)
            Reporter:
            zhang mengzhi
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: