Details
-
Task
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
Query Integration
-
Fully Compatible
-
QI 2023-08-21, QI 2023-09-04, QI 2023-09-18
-
0
Description
A query like ts.aggregate({$group: {_id: "$meta", m: {$min: "$control.min.value"}}}) should be optimized to take advantage of the bucket's control data instead of unpacking the buckets.
When all queries against TS namespace are forced to run in classic, both ts.aggregate({$group: {_id: "$meta", m: {$min: "$value"}}}) and system.buckets.ts..aggregate({$group: {_id: "$meta", m: {$min: "$control.min.value"}}}) generate the following plan:
"stages" : [
|
{
|
"$cursor" : {
|
"queryPlanner" : {
|
"namespace" : "my.system.buckets.ts",
|
"indexFilterSet" : false,
|
"parsedQuery" : {
|
},
|
"queryHash" : "0D1EB9EE",
|
"planCacheKey" : "0D1EB9EE",
|
"maxIndexedOrSolutionsReached" : false,
|
"maxIndexedAndSolutionsReached" : false,
|
"maxScansToExplodeReached" : false,
|
"winningPlan" : {
|
"stage" : "PROJECTION_DEFAULT",
|
"transformBy" : {"control.min.value" : 1, "meta" : 1, "_id" : 0},
|
"inputStage" : {"stage" : "COLLSCAN", "direction" : "forward"}
|
},
|
"rejectedPlans" : [ ] }}},
|
{ "$group" : {"_id" : "$meta", "m" : {"$min" : "$control.min.value"}}}
|
],
|
But if SBE lowered is allowed for TS namespaces, the query against the view only lowers the access (PROJECTION_DEFAULT + COLLSCAN) but not GROUP while the query against the backing collection is lowered fully (GROUP + COLLSCAN). This needs to be investigated because not lowering the $group properly is likely to affect performance.