I’m rather going round in circles on this question.
The lecture in Chapter 6, Aggregation performance, gives some explicit techniques for optimizing a pipeline.
The lectures on pipeline optimization explore the “explain” option and show how the MongoDB pipeline optimizer works.
Applying these techniques to some of the possible solutions for this question it can be seen that the optimizer elevates $match and $sort queries to the front of the pipeline to take advantage of the indexes. The optimizer will also split compound $match statements if part of the $match can use an index.
The resultant ‘plans’ are so similar that I’m finding it next to impossible to ascertain which is the ‘best’
Can anyone point me to additional resources that might help, please?