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

when sharded, no need to merge groups if $group _id is the shard key or original document _id

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      QuInt 8 08/28/15

      Description

      Copied from SERVER-4961:

      On sharded environment, using early grouping, besides the use of an index, it would be nice that we be able to avoid the mongos regrouping process.

      I'll try to explain that:

        * result_node1: [
           {
             id: "value1",
             totalcount: 50
           },
           {
             id: "value2",
             totalcount: 100
           },
         ]
       * result_node2: [
           {
             id: "value1",
             totalcount: 60
           }
         ]
      

      The real results(after mongos regroup) must looks like:

       [
           {
             id: "value1",
             totalcount: 110
           },
           {
             id: "value2",
             totalcount: 100
           },
       ]
      

      But, in some cases, mongos regrouping process is nonsense since the grouping key is same as sharding key. So, never got same group key from different shards.

      So, the prior example, now looks like:

        * result_node1: [
           {
             id: "value1",
             totalcount: 110
           }
         ]
       * result_node2: [
           {
             id: "value2",
             totalcount: 100
           }
         ]
      

      The real results must looks like:

       [
           {
             id: "value1",
             totalcount: 110
           },
           {
             id: "value2",
             totalcount: 100
           },
       ]
      

      So, the point is mongos regrouping process is a waste of time when you group using same key as sharding key.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                7 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated: