Forum: Ruby on Rails Fast inserts?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bogdan I. (Guest)
on 2006-02-26 19:26
(Received via mailing list)
There are cases when I have to create the same record 100 times.
Is there a faster way than:
100.times{Obj.create(@params[:obj])} ?

Steve L. (Guest)
on 2006-02-26 23:33
(Received via mailing list)
Dare I ask, but why do you need to do this?
Pat M. (Guest)
on 2006-02-26 23:39
(Received via mailing list)
100 records isn't really a lot..

Anyway, when AR does an insert, it wraps it in a transaction.  You'll
get a nice performance boost if you wrap the iterator itself in a
transaction.  So instead of begin..insert..commit..begin..etc it'll be
like begin..insert..insert..insert..commit.

Bogdan I. (Guest)
on 2006-02-27 00:12
(Received via mailing list)
Well, it's a game, and you can have objects that are initially
but evolve differently. Adding a counter for identical object would be a
hassle since most of them stay in their initial shape for seconds or
This topic is locked and can not be replied to.