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

【query plans issue】inappropriate candidate plans are generated

    XMLWordPrintableJSON

Details

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

    Description

      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.

      Attachments

        Activity

          People

            daniel.hatcher@mongodb.com Danny Hatcher (Inactive)
            z572505258 zhang mengzhi
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: