-
Type: Investigation
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Not Needed
In some cases for timeseries (example below) optimizer may replace $group with $_internalStreamingGroup stage.
In addition to all $group fields, it will also contain $monotonicIdFields field that lists all _id fields that are considered monotonic by the optimizer. If _id is a single expression, it will just contain a single element “_id”.
Example of explain output with the new stage
{
"explainVersion" : "1",
"stages" : [
{
"$cursor" : {
"queryPlanner" : {
"namespace" : "timeseries.system.buckets.Collection0",
"indexFilterSet" : false,
"parsedQuery" : {
},
"queryHash" : "17830885",
"planCacheKey" : "17830885",
"maxIndexedOrSolutionsReached" : false,
"maxIndexedAndSolutionsReached" : false,
"maxScansToExplodeReached" : false,
"winningPlan" :
,
"rejectedPlans" : [ ]
}
}
},
{
"$_internalUnpackBucket" :
,
"command" : {
"aggregate" : "system.buckets.Collection0",
"pipeline" : [
{
"$_internalUnpackBucket" :
},
{
"$_internalBoundedSort" : {
"sortKey" :
,
"bound" :
,
"limit" : NumberLong(0)
}
},
{
"$_internalStreamingGroup" : {
"_id" : {
"symbol" : "$symbol",
"time" : {
"$dateTrunc" : {
"date" : "$time",
"unit" :
,
"binSize" :
}
}
},
"high" :
,
"low" :
,
"open" :
,
"close" :
,
"$monotonicIdFields" : [
"time"
]
}
}
],
"serverInfo" :
,
"serverParameters" :
,
"command" : {
"aggregate" : "system.buckets.Collection0",
"pipeline" : [
{
"$_internalUnpackBucket" :
},
{
"$sort" :
},
{
"$group" : {
"_id" : {
"symbol" : "$symbol",
"time" : {
"$dateTrunc" :
}
},
"high" :
,
"low" :
,
"open" :
,
"close" :
}
}
],
"cursor" : {
},
"collation" :
},
"ok" : 1
}
Description of Linked Ticket
null
- depends on
-
SERVER-70267 Streaming group when id is on time
- Closed