Skip to content

Instantly share code, notes, and snippets.

@bachue
Created March 22, 2013 03:45
Show Gist options
  • Save bachue/5218807 to your computer and use it in GitHub Desktop.
Save bachue/5218807 to your computer and use it in GitHub Desktop.
jobs_per_process = 100
process_count = 10
User.find_in_batches(:batch_size => jobs_per_process * process_count, :conditions => "name like '%00'") do |group|
batches = group.in_groups(process_count)
batches.each do |batch|
Process.fork do
ActiveRecord::Base.establish_connection
batch.reject { |user| user.nil? }.
each {|user| puts user.name }
end
end
Process.waitall
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment