ActiveRecord: reducing memory footprint with find

Hi,
My script that uses ActiveRecord to retreive about 1mil of records from
database runs out of memory in about 10 second and crashes. Is there any
way to significantly reduce memory footprint? The line in question is a
simple object.find(:all, :conditions => “…”)

Help would be much appreciated.
Thanks
Petr

On 16 Jan 2008, at 10:42, Petr J. wrote:

Hi,
My script that uses ActiveRecord to retreive about 1mil of records
from
database runs out of memory in about 10 second and crashes. Is there
any
way to significantly reduce memory footprint? The line in question
is a
simple object.find(:all, :conditions => “…”)

Well using :select to only fetch needed columns would help. I would
expect that dropping down to the level of
ActiveRecord::Base.connection.select_all would save you something as
well, but obviously you’re not dealing with ActiveRecord objects
anymore.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs