Reputation: 41
I'm using mongoose in my project. When the number of documents in my collection becomes bigger, the method of find+sort becomes slower. So I use aggregate+$sort instead. I just wonder why?
Upvotes: 4
Views: 3745
Reputation: 5466
Without seeing your data and your query it is difficult to answer why aggregate+sort is faster than find+sort.
But below are the things that holds good on find and aggregate
see this thread for more info
MongoDB {aggregation $match} vs {find} speed
Upvotes: 4