Looking for some direction here.
The aggregation query includes a $sort stage, but from what I can tell that stage provides no functional purpose to the query. Do we just use the aggregation query as provided even though it includes a meaningless $sort stage? Or do you expect that we would look to modify the query? (the reason I ask is that the best index would likely be different if we didn’t need to sort on stars. The memory exception would also go away, but I expect there would still be value in building an index for other perf reasons).
As well, is the essence of “smallest index” in the question intended to include the concept of Partial Index? I’ve created an index on {stars: 1, cuisine: 1} where {stars: $gt 2}. I would expect the query to use this index, but for some reason it is deferring to a COLLSCAN.
Can you provide some guidance?