Bulk Inserts. Fast way to insert 1000s records?

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

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.
[email protected]

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
[email protected]
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.