I’d love to receive some feedback and guidance. The most important thing for me is: is this something we’d like to have in Active Record? If so, I’d be able to start working on this next week. If not, I’d love to contribute in another way.
I am interested in bulk inserts as active Rails user.
The use cases for that are somewhat rare, but when you need for example import some dictionary from 15 GB XML file to your DB, that will take literally days to complete, and one of the bottlenecks (except XML parsing) will be a lot of INSERTS with waiting for completion of each statement. Bulk INSERTs may really help there.
Sorry, I’m just a user and can’t help you with any guidance in ActiveRecord (really I need such a guidance too in my own work).
If you are looking for performance, you should use the database interface directly like COPY for simple case like text, CSV or I think JSON.
Furthermore, you are talking to use a gem for this feature but I discovered that gem https://github.com/jamis/bulk_insert which provides the bulk import. I don’t know if that gem does what you are looking for.
It works well and is fairly mature and still maintained. I don’t believe it implements COPY, as that tend to be very DBMS-specific in syntax, but the way it optimizes use of INSERTs is much faster than anything you can do with regular active_record. You can also work with (import) raw columns and arrays of values instead of instantiating active_record model objects, which can save a ton of memory when dealing with many records.