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

Optimize plan generation for accumulators to not use Traverse

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Query Execution

    Description

      Accumulators ignore arrays or treat them as whole values. 

      A $min doesn't traverse into an array to find the min  of 1,

      > db.c.insert({a: 1, x: [1, 99]})
      WriteResult({ "nInserted" : 1 })
      > db.c.insert({a: 2, x: 10})
      WriteResult({ "nInserted" : 1 })
      > db.c.insert({a: 1, x: 10})
      WriteResult({ "nInserted" : 1 })
      > db.c.aggregate([{$group: {_id: "$a", m: {$min: "$x"}}}])
      { "_id" : 1, "m" : 10 }

      A $min where a 'false' is compared to an array chooses the min as the array,

      db.c.insert({a: 3, x: false})
      db.c.insert({a: 3, x: [1,2]})
      > db.c.aggregate([{$group: {_id: "$a", m: {$min: "$x"}}}])
      { "_id" : 1, "m" : 10 }
      { "_id" : 3, "m" : [ 1, 2 ] }
      { "_id" : 2, "m" : 10 }

      This all means that we don't implicitly traverse arrays so could generate plans that chain together getFields() over the dotted paths instead of plans that use the sbe traverse stage.

       

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            eric.cox@mongodb.com Eric Cox (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: