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

【query plans issue】inappropriate candidate plans are generated

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 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. 

      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:
            daniel.hatcher@mongodb.com Danny Hatcher (Inactive)
            Reporter:
            z572505258 zhang mengzhi
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: