From: Brian Le Roy Date: 2005-09-10T02:38:45+09:00 Subject: Re: general performance question I compiled the C bindings. I'll try building arrays and pass those. Thanks for all the help! Robert Klemme wrote: > 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? > > > Unlikely, as the data has to be fetched over the network (even if it's > local). Even with prefetching etc. this is slower than iterating an array > in mem. Also, the accumulated time of each depends on the complexity of > the operation in the block - that's sometimes overlooked. Note that #each > is called only once per iteration but the block is invoked multiple times. > > Kind regards > > robert > > >