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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -