Bulk Inserts. Fast way to insert 1000s records?


#1

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


#2

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


#3

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.