Created
July 3, 2012 05:46
-
-
Save csanz/3037938 to your computer and use it in GitHub Desktop.
You'd be shocked how fast this query runs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var users = [] | |
db.users.find({}, {_id:1}).limit(15000).forEach(function(data){ users.push(data._id) }) | |
db.activities.find({'user.id': { $in: users }}).sort({created_at: -1}) | |
// in less than 2 secs. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment