merge sequential $project stages and $addFields stages when appropriate

XMLWordPrintableJSON

    • Query Optimization
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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:
              [DO NOT USE] Backlog - Query Optimization
              Reporter:
              Adinoyi Omuya (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              13 Start watching this issue

                Created:
                Updated: