java - Mongodb / Jongo sorting then limit, vs, limit then sorting -
are these 2 guaranteed same:
collection.limit(10).sort("{score: -1}")
vs
collection.sort("{score: -1}").limit(10)
the second 1 global sort, , returns top 10. first 1 guaranteed same, or may return 10 sorted records?
thanks
in normal queries, sort
processed first, skip
, , limit
, no matter in order add them cursor object.
the aggregation framework execute $sort
, $skip
, limit
operators in order of appearance in pipeline.
Comments
Post a Comment