I am creating a new table that needs to be populated with data based on user accounts (over several tens of thousands) with the next one-time rake task.
What I decided to do was create a large INSERT string for every 2000 users and execute this query.
Here's what it looks like:
task :backfill_my_new_table => :environment do inserts = [] User.find_each do |user| tuple =
So I'm wondering if there is a better way to do this? What are some of the disadvantages of the approach I took? How can I improve it? What if I didn’t slice the inserts
array and just execute a single INSERT
with more than two tens of thousands of VALUES tuples? What are the disadvantages of this method?
Thanks!
source share