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

Modify explain output for aggregations against mongos which target unsharded collections

    • Query
    • ALL
    • Hide

      On a sharded cluster

      1. Create unsharded collection
      2. Execute explain of an aggregate command with a single $out stage (defaulting to replace existing collection)
        Expected results:

      stages array is at the top level of the explain output

      Actual results

      stages array is nested within shards.<shard name>

      Sample output:

      {
        "splitPipeline" : null,
        "shards" : {
          "sh02" : {
            "host" : "localhost:27218",
            "stages" : [{
                "$cursor" : {
                  "query" : { },
                  "queryPlanner" : {
                    "plannerVersion" : 1,
                    "namespace" : "JavaDriverTest.com.mongodb.operation.AggregateToCollectionOperationSpecification",
                    "indexFilterSet" : false,
                    "parsedQuery" : { },
                    "queryHash" : "8B3D4AB8",
                    "winningPlan" : {
                      "stage" : "FETCH",
                      "inputStage" : {
                        "stage" : "IXSCAN",
                        "keyPattern" : {
                          "a" : 1
                        },
                        "indexName" : "a_1",
                        "isMultiKey" : false,
                        "multiKeyPaths" : {
                          "a" : []
                        },
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 2,
                        "direction" : "forward",
                        "indexBounds" : {
                          "a" : ["[MinKey, MaxKey]"]
                        }
                      }
                    },
                    "rejectedPlans" : []
                  }
                }
              }, {
                "$out" : {
                  "to" : "outputCollection",
                  "db" : "JavaDriverTest",
                  "mode" : "replaceCollection",
                  "uniqueKey" : {
                    "_id" : 1
                  }
                }
              }]
          }
        },
        "ok" : 1.0,
         ...
      }
      
      Show
      On a sharded cluster Create unsharded collection Execute explain of an aggregate command with a single $out stage (defaulting to replace existing collection) Expected results: stages array is at the top level of the explain output Actual results stages array is nested within shards.<shard name> Sample output: { "splitPipeline" : null, "shards" : { "sh02" : { "host" : "localhost:27218", "stages" : [{ "$cursor" : { "query" : { }, "queryPlanner" : { "plannerVersion" : 1, "namespace" : "JavaDriverTest.com.mongodb.operation.AggregateToCollectionOperationSpecification", "indexFilterSet" : false, "parsedQuery" : { }, "queryHash" : "8B3D4AB8", "winningPlan" : { "stage" : "FETCH", "inputStage" : { "stage" : "IXSCAN", "keyPattern" : { "a" : 1 }, "indexName" : "a_1", "isMultiKey" : false, "multiKeyPaths" : { "a" : [] }, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : 2, "direction" : "forward", "indexBounds" : { "a" : ["[MinKey, MaxKey]"] } } }, "rejectedPlans" : [] } } }, { "$out" : { "to" : "outputCollection", "db" : "JavaDriverTest", "mode" : "replaceCollection", "uniqueKey" : { "_id" : 1 } } }] } }, "ok" : 1.0, ... }

      On master with a sharded cluster but an unsharded collection, the stages array in the explain output of an aggregate command with hint and $out is nested in shards.<shard name>. This is different than 4.0 and earlier branches, in which the stages array is at the top level.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: