Yes, an index/caching will make the lookup faster, but even at the 
optimum you are looking at 6000 transactions. Never in two seconds 
unless you have some unsafe (buffered, no fsync) setting on your db engine.

Cheers,
Gary.

Colin Law wrote:
> Would not the index make the lookup faster but the write slower?  Is it 
> that the cacheing would mean that the lookup would be pretty quick 
> anyway, even without an index?
> 
> Colin
> 
> 2009/5/9 Gary Doades <g...@gpdnet.co.uk <mailto:g...@gpdnet.co.uk>>
> 
> 
>     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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to