Jian Lin wrote: > Gary Doades wrote: > >> If you have made the change to count up words first and then *insert* >> all the (word,count) records into the database in a *single* transaction >> then it ought to take less than a second. I would expect that the total >> number of (word,count) records is in the order or hundreds or perhaps a >> thousand or so? Any decent DB ought to insert that in under a second as >> a *single* transaction. >> >> If it is still taking minutes then you are probably not doing the above >> somehow. I think in that case you need to post your code again so we can >> see what it is doing now. > > > i was doing it like this: > > > all_phrases = frequencies.keys > Phrase.transaction do > all_phrases.each do |phrase| > recordPhrase = Phrase.new(:s => phrase, :frequency => > frequencies[phrase], :length => lengths[phrase]) > recordPhrase.save > end > end > > > i am using "Phrase" instead of "Word"... but it is the same thing... > > all_phrases.length is about 34000 for all data...
I'm not sure how you get 34000 records from 6000 words. Surely you should get less not more. > it would run for at least a minute... that's kind of weird... > Are you sure it is just the above code that is taking a minute and not the bit of code that counts the words? What hardware is this on exactly? Cheers, Gary. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

