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])} ? Bogdan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060226/75d1e099/attachment.html
Dare I ask, but why do you need to do this? On 2/26/06, Bogdan Ionescu <bogdan.ionescu@gmail.com> wrote:> > 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])} ? > > Bogdan > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060226/53e161ca/attachment.html
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. Pat On 2/26/06, Bogdan Ionescu <bogdan.ionescu@gmail.com> wrote:> 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])} ? > > Bogdan > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Well, it''s a game, and you can have objects that are initially identical, 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 minutes. On 2/26/06, Steve Longdo <steve.longdo@gmail.com> wrote:> > Dare I ask, but why do you need to do this? > > On 2/26/06, Bogdan Ionescu <bogdan.ionescu@gmail.com> wrote: > > > 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])} ? > > > > Bogdan > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060226/43234a0e/attachment.html