From: James F. H. <jf...@ci...> - 2002-04-18 03:07:07
|
I noticed in the archives that others had reported the performance problem with dbd_pg. It turns out the problem lies in the repeated calling of PGResult#result by fetchrow. PGResult#result creates the result array each time it's called. The following patch takes care of the problem in DBD::Pg by caching the result array, though it may be better to have the postgres driver cache the result array after the first call instead. *** Pg.rb Sun Dec 2 12:23:59 2001 --- /local/lib/ruby/site_ruby/1.7/DBD/Pg/Pg.rb Tue Apr 16 23:07:17 2002 *************** *** 452,457 **** --- 452,458 ---- @db = db @pg_result = pg_result @index = -1 + @result = @pg_result.result @row = Array.new end *************** *** 461,468 **** def fetchrow @index += 1 ! if @index < @pg_result.result.size ! fill_array(@pg_result.result[@index]) else @row = nil end --- 462,469 ---- def fetchrow @index += 1 ! if @index < @result.size ! fill_array(@result[@index]) else @row = nil end ---------------------------------------------------------------------- | Jim Hranicky, Senior SysAdmin UF/CISE Department | | E314D CSE Building Phone (352) 392-1499 | | jf...@ci... http://www.cise.ufl.edu/~jfh | ---------------------------------------------------------------------- |