Forum: Ruby on Rails Bulk Inserts. Fast way to insert 1000s records?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chris R. (Guest)
on 2006-05-09 14:01
Hi,

This code loops through my results and saves them :

@results.each{|r| r.save}

There are potentially thousands of results.  This takes ages to
complete.
Is there a quicker way to do this?

Any help is greately appreciated
Thanks
Chris
Jack C. (Guest)
on 2006-05-09 17:05
(Received via mailing list)
Chris R. wrote:

>Any help is greately appreciated
>Thanks
>Chris
>
>
>
Wrapping this in a transaction block should offer some improvement
provided your db supports transactions.

--
Jack C.
removed_email_address@domain.invalid
Richard W. (Guest)
on 2006-05-09 17:33
(Received via mailing list)
On Tuesday, May 09, 2006, at 12:01 PM, Chris R. wrote:
>Any help is greately appreciated
>Thanks
>Chris
>
>--
>Posted via http://www.ruby-forum.com/.
>_______________________________________________
>Rails mailing list
>removed_email_address@domain.invalid
>http://lists.rubyonrails.org/mailman/listinfo/rails


At the extreme - - you can write your data to a temporary CSV file then
use the native database bulk loader (assuming there is one) to do the
load.
This topic is locked and can not be replied to.