How to Process Large Data Sets with Ruby
The need for data migrations in mature systems is real. At times, requests for these migrations can appear at random. One minute, a system is behaving as specified, happily fulfilling requests, and then bam! All the user objects suddenly need an extremely crucial attribute. Find out how to do such a data migration in a fast and efficient way.
Comments
I think by far the best way to handle this is using some simple (Postgre)SQL:
rb User.update_all("phone_number = '+1' || phone_number")This is now several orders of magnitude faster and you shouldn’t need any background jobs.
You can also use something like this (as well on a SQL level): http://stackoverflow.com/questions/4271186/how-can-i-use-mysql-replace-to-replace-strings-in-multiple-records
Post a comment