|
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.
|