Last active
August 29, 2015 14:08
-
-
Save bgvo/0bc834251d3dcbcf588a to your computer and use it in GitHub Desktop.
Getting incrementing ranges of data (over a million of docs)
This file contains 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
olds = Item.order_by(id: 1).skip(new_batch*10000).limit(10000).not_in(id: set) | |
olds.each do |doc| | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
using skip is a bad idea in any database, if you have a time field you should use it to paginate also $nin can be slow specially if "set" is big so maybe you should add a a field to know if the Item was processed
if it is not enough and you need more speed you should use moped directly and also use no_timeout option to avoid
Don't forget add indexes for t and processed