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

Improve explain output of aggregation command in sharded cluster

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.4
    • Affects Version/s: 3.1.2
    • Component/s: Aggregation Framework
    • None
    • Minor Change
    • Quint Iteration 4

      When the aggregation pipeline is executed against a sharded collection, you get something like the following:

      mongos> db.foo.explain().aggregate([{$project: {i: 1}}])
      {
      	"splitPipeline" : {
      		"shardsPart" : [
      			{
      				"$project" : {
      					"i" : true
      				}
      			}
      		],
      		"mergerPart" : [ ]
      	},
      	"shards" : {
      		"shard0000" : {
      			"host" : "franklinia:30000",
      			"stages" : [
      				{
      					"$cursor" : {
      						"query" : {
      							
      						},
      						"fields" : {
      							"i" : 1,
      							"_id" : 1
      						},
      						"queryPlanner" : {
      							"plannerVersion" : 1,
      							"namespace" : "test.foo",
      							"indexFilterSet" : false,
      							"parsedQuery" : {
      								"$and" : [ ]
      							},
      							"winningPlan" : {
      								"stage" : "SHARDING_FILTER",
      								"inputStage" : {
      									"stage" : "COLLSCAN",
      									"filter" : {
      										"$and" : [ ]
      									},
      									"direction" : "forward"
      								}
      							},
      							"rejectedPlans" : [ ]
      						}
      					}
      				},
      				{
      					"$project" : {
      						"i" : true
      					}
      				}
      			]
      		}
      	},
      	"ok" : 1
      }
      

      If the pipeline is not executed on a sharded collection, or if we have determined that only one shard needs to run the command, you get something like this:

      mongos> db.foo.explain().aggregate([{$project: {i: 1}}])
      {
      	"stages" : [
      		{
      			"$cursor" : {
      				"query" : {
      					
      				},
      				"fields" : {
      					"i" : 1,
      					"_id" : 1
      				},
      				"queryPlanner" : {
      					"plannerVersion" : 1,
      					"namespace" : "test.foo",
      					"indexFilterSet" : false,
      					"parsedQuery" : {
      						"$and" : [ ]
      					},
      					"winningPlan" : {
      						"stage" : "COLLSCAN",
      						"filter" : {
      							"$and" : [ ]
      						},
      						"direction" : "forward"
      					},
      					"rejectedPlans" : [ ]
      				}
      			}
      		},
      		{
      			"$project" : {
      				"i" : true
      			}
      		}
      	],
      	"ok" : 1
      }
      

      This output should somehow mention that it was run directly on one shard, and display the host name of that shard.

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: