-
Type:
Improvement
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: 3.1.2
-
Component/s: Aggregation Framework
-
None
-
Minor Change
-
Quint Iteration 4
-
None
-
None
-
None
-
None
-
None
-
None
-
None
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.
- is related to
-
SERVER-7656 Optimize aggregation on sharded setup if first stage is exact match on shard key
-
- Closed
-