From: Joe Van Dyk Date: 2005-09-10T00:04:19+09:00 Subject: Re: general performance question That's odd that it would take so long with only 20 records in the result set. With 140k in the result set, that would be expected, I suppose. But not 20. Are you using the C mysql bindings, or the pure Ruby bindings? On 9/9/05, Brian Le Roy wrote: > Thanks Robert! > > I think I found the culprit. > > With 20 records in the result: > total ms/call > 12300.00 Mysql::Result#each > > With 1 record in the result: > total ms/call > 600.00 Mysql::Result#each > > The query behind this result set is indexed properly. Not sure why this > takes so long - shouldn't it be as fast as a regular array.each call? > > Robert Klemme wrote: > > Brian Le Roy wrote: > > > >>Actually guys, I took out the queries - except for one that is run > >> once. Same behaviour in top. I'm going to start marking out the > >>app with > >>the benchmark module and hopefully that will shed some light on it! > > > > > > Note also that there is ruby -r profile. That way you don't have to > > manually change your code. > > > > robert > > > > > >>Robert Klemme wrote: > >> > >>>Reid Thompson wrote: > >>> > >>> > >>>>Brian Le Roy wrote: > >>>> > >>>> > >>>>>no, but the table has 140K records. the disk isn't crunching, so > >>>>>the index should be okay. i was thinking it would be passing > >>>>>around the database connection object causing overhead. i took > >>>>>the result set object and created a straight ol' array for > >>>>>passing. no improvement - so maybe there's nothing to do. thanks > >>>>>for all the responses - i'll keep messing with it and if i find > >>>>>something that improves it, i'll let you know! > >>>>> > >>>>>bonefry wrote: > >>>>> > >>>>> > >>>>>>Well, that's it. > >>>>>> > >>>>>>MySql can take even 100% of your processing power. It happenes > >>>>>>when you have complex queries to run, and you run them on big > >>>>>>tables. Are you running complex queries ? > >>>>>> > >>>>>> > >>>>>> > >>>>> > >>>>It may may no difference, but you could try the same with > >>>>postgresql, or maybe even sqlite, to see if it is mysql thats the > >>>>issue. > >>> > >>> > >>>Before he does that I'd try a different query frontend to see whether > >>>performance characteristics stay the same (i.e. time is spent in the > >>>DB, which would be my guess). The overhead is much smaller compared > >>>to installing another DBMS, transferring DDL and data to that. > >>> > >>>Kind regards > >>> > >>> robert > > > > > > > > > >