From: Brian Le Roy Date: 2005-09-09T23:55:46+09:00 Subject: Re: general performance question 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 > > > >