Details
-
Improvement
-
Resolution: Unresolved
-
Major - P3
-
None
-
None
-
None
-
None
-
Query Optimization
Description
I was working with cheahuychou.mao@mongodb.com to investigate some ways to improve performance of an internal sharding query and we noticed that the first of these two generates a covered plan, and the second does not:
{"$project": {"_id": 0, "key": {"$meta": "indexKey"}}},
|
{
|
"$group": {
|
"_id": {"key0": {"$getField": {"field": "a.y.ii", "input": "$key"}}},
|
"frequency": {"$sum": 1}
|
}
|
},
|
{
|
"$group": {
|
"_id": {
|
"$let": {vars: {key: {"$meta": "indexKey"}},
|
"in": {
|
"key0": {"$getField": {"field": "a.y.ii", "input": "$$key"}}}
|
}
|
},
|
"frequency": {"$sum": 1}
|
}
|
},
|
Explains are attached.
Attachments
Issue Links
- related to
-
SERVER-78105 Optimize the aggregation pipeline used by analyzeShardKey command to calculate cardinality and frequency
-
- Closed
-