Wednesday, 7 August 2013

Mongodb / Jongo sorting then limit, vs, limit then sorting

Mongodb / Jongo sorting then limit, vs, limit then sorting

Are these two guaranteed to be the same:
collection.limit(10).sort("{score: -1}")
vs
collection.sort("{score: -1}").limit(10)
The second one does a global sort, and returns the top 10. Is the first
one guaranteed to do the same, or may it just return 10 sorted records?
Thanks

No comments:

Post a Comment