-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
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.
- related to
-
SERVER-78105 Optimize the aggregation pipeline used by analyzeShardKey command to calculate cardinality and frequency
- Closed