On May 9, 5:48 pm, Jian Lin <[email protected]> wrote:
> Colin Law wrote:
> > Is this a test or a real requirement? If it is a real requirement then
> > count the words in memory first and then update the db so each record is
> > only written once.
>
> > Colin
>
> > 2009/5/9 Jian Lin <[email protected]>
>
> it is a real requirement... so how do i update the db at the end in 1
> operation? thanks.
Well like others have said you can wrap everything in a single
transaction (look at the rails api docs for transactions) which at
least means that your database won't have to flush to disk on each
write. There's nothing built into rails for bulk inserts but there's
nothing stopping you from building up the appropriate insert statement
yourself (there's also a plugin (http://github.com/zdennis/ar-
extensions/tree/master) that does that sort of thing).
Fred
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---