I'm glad you said it was a test because it wouldn't be nice to do that 
for real.

It looks like you've got at least 12000 transactions in there (select + 
update). Any indexes would make it worse.

I'm guessing that this would take around 5 minutes on decent single disk 
  PC hardware.

No database engine (even oracle) is going to do that in 2 seconds on a 
standard PC with a single sata/ide hard disk. You're asking for 6000 
read/write operations per second. You'll need some mighty big hardware 
to do that!

If you did the whole thing in a single transaction you might get it to 
go quite a bit faster.

Cheers,
Gary.

Jian Lin wrote:
> i am writing a test program for ActiveRecord, and it reads a document
> which is like 6000 words long.  And then i just tally up the words by
> 
>     recordWord = Word.find_by_s(word);
>     if (recordWord.nil?)
>       recordWord = Word.new
>       recordWord.s = word
>     end
>     if recordWord.count.nil?
>       recordWord.count = 1
>     else
>       recordWord.count += 1
>     end
>     recordWord.save
> 
> and so this part loops for 6000 times... and it takes a few minutes to
> run at least using sqlite3.  Is it normal?  I was expecting it could run
> within a couple seconds...  can MySQL speed it up a lot?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to