Ordering of limit and sort has any effect in query execution

16 views
Skip to first unread message

Sandy

unread,
Jun 20, 2012, 1:29:03 PM6/20/12
to mongodb-user
Hi

Does Ordering of limit and sort has any effect in query execution

Are both queries same or different

1) db.foo.find( { _id: { $gt : "ABCD"} }).limit(4).sort({_id:1})

2) db.foo.find( { _id: { $gt : "ABCD"} }).sort({_id:1}).limit(4)

Thanks
Sandy

Sid

unread,
Jun 20, 2012, 2:21:54 PM6/20/12
to mongod...@googlegroups.com
It shouldn't. You can verify this using explain on the queries. Here's the page that tells what explain returns : http://www.mongodb.org/display/DOCS/Explain
Reply all
Reply to author
Forward
0 new messages