Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-79066

Investigate why $group rewrite based on controls in TS isn't lowered to SBE

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Query Integration
    • Fully Compatible
    • QI 2023-08-21, QI 2023-09-04, QI 2023-09-18
    • 0

      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.

            Assignee:
            irina.yatsenko@mongodb.com Irina Yatsenko (Inactive)
            Reporter:
            irina.yatsenko@mongodb.com Irina Yatsenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: