MongoDB : Aggregation framework : Get last dated document per grouping ID
To directly answer your question, yes it is the most efficient way. But I do think we need to clarify why this is so. As was suggested in alternatives, the one thing people are looking at is “sorting” your results before passing to a $group stage and what they are looking at is the “timestamp” … Read more