Ask for Help
“Does Active Record have batched insert? I need to dump 10,000 rows into the database in process and I don’t want it to take 45 seconds.”
The upshot: use a raw SQL INSERT statement.
Interesting Things
For a day as interesting as today (1/11/11 anyone?) there were surprisingly few interesting things of note.
Creating many records is exactly what the activerecord-import gem was made for.
January 11, 2011 at 10:07 am
When we do big inserts, we often use this handy utility module: https://gist.github.com/7681
It provides a decent interface to MySQL’s INSERT ON DUPLICATE KEY UPDATE functionality which is really nice for avoiding the race conditions / rescue / retry you sometimes run into with plain old validates_uniqueness_of
January 11, 2011 at 10:36 am