Here's an example where there are two $projects in an agg pipeline against a time-series view.
> coll.explain().aggregate([ { “$sort” : { “_id” : 1 } }, { “$project” : { “x” : 1 } } ])
{
“explainVersion” : “1",
“stages” : [
{
“$cursor” : {
“queryPlanner” : {
“namespace” : “test.system.buckets.timeseries_bucket_limit_count_1”,
“indexFilterSet” : false,
“parsedQuery” : {
},
“queryHash” : “8B3D4AB8”,
“planCacheKey” : “8B3D4AB8”,
“maxIndexedOrSolutionsReached” : false,
“maxIndexedAndSolutionsReached” : false,
“maxScansToExplodeReached” : false,
“winningPlan” : {
“stage” : “COLLSCAN”,
“direction” : “forward”
},
“rejectedPlans” : [ ]
}
}
},
{
“$_internalUnpackBucket” : {
“include” : [
“_id”,
“x”
],
“timeField” : “time”
}
},
{
“$project” : {
“_id” : true,
“x” : true
}
},
{
“$sort” : {
“sortKey” : {
“_id” : 1
}
}
},
{
“$project” : {
“_id” : true,
“x” : true
}
}
],
“serverInfo” : {
“host” : “cedar”,
“port” : 27017,
“version” : “4.9.0-alpha4-383-g142e95a”,
“gitVersion” : “142e95a1dc2a2ba9c90ea610c30ee697e880e967”
},
“command” : {
“aggregate” : “system.buckets.timeseries_bucket_limit_count_1",
“pipeline” : [
{
“$_internalUnpackBucket” : {
“timeField” : “time”,
“exclude” : [ ]
}
},
{
“$sort” : {
“_id” : 1
}
},
{
“$project” : {
“x” : 1
}
}
],
“cursor” : {
},
“collation” : {
“locale” : “simple”
}
},
“ok” : 1
}
The new project which appears first is internalized but isn't removed from the pipeline.
- duplicates
-
SERVER-54864 Peform dependancy analysis and include/exclude internalization in one step
-
- Closed
-