Skip to content

Instantly share code, notes, and snippets.

@csanz
Created July 3, 2012 05:46
Show Gist options
  • Save csanz/3037938 to your computer and use it in GitHub Desktop.
Save csanz/3037938 to your computer and use it in GitHub Desktop.
You'd be shocked how fast this query runs
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