[SERVER-18444] Improve explain output of aggregation command in sharded cluster Created: 12/May/15  Updated: 25/Jun/15  Resolved: 28/May/15

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.1.2
Fix Version/s: 3.1.4

Type: Improvement Priority: Major - P3
Reporter: Charlie Swanson Assignee: Charlie Swanson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-7656 Optimize aggregation on sharded setup... Closed
Backwards Compatibility: Minor Change
Sprint: Quint Iteration 4
Participants:

 Description   

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.



 Comments   
Comment by Charlie Swanson [ 28/May/15 ]

Fixed with https://github.com/mongodb/mongo/commit/7d526bbc47681fd297d38cdc577a9a7d710f7a99

Generated at Thu Feb 08 03:47:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.