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

merge sequential $project stages and $addFields stages when appropriate

    • Query Optimization

      Consider

      {"$project": {"__joinedPipeline_1_c":"$c","__joinedPipeline_1_e":"$e","_id":"$__joined_bar._id","c":"$__joined_bar.c"}},
      {"$project": {"__joinedPipeline_1_c":1,"__joinedPipeline_1_e":1,"_id":1,"bar_DOT__id":"$_id","bar_DOT_c":"$c","c":1}},
      {"$project":{"bar_DOT_c":"$c","foo_DOT_e":"$__joinedPipeline_1_e"}}
      

      The pipeline can be consolidated into a single $project stage:

      {"$project":{"bar_DOT_c":"$__joined_bar.c","foo_DOT_e":"$e"}}

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            adinoyi.omuya@mongodb.com Adinoyi Omuya
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: