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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -