# ActiveRecord: reducing memory footprint with find

**URL:** <https://www.ruby-forum.com/t/activerecord-reducing-memory-footprint-with-find/126215>\
**Category:** Rails\
**Created:** [January 16, 2008, 11:42am UTC](https://www.ruby-forum.com/t/activerecord-reducing-memory-footprint-with-find/126215 "2008-01-16T11:42:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![petrjanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@petrjanda](https://www.ruby-forum.com/u/petrjanda)\
**Post date:** [January 16, 2008, 11:42am UTC](https://www.ruby-forum.com/t/activerecord-reducing-memory-footprint-with-find/126215/1 "2008-01-16T11:42:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![petrjanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@petrjanda](https://www.ruby-forum.com/u/petrjanda)\
**Post date:** [January 16, 2008, 12:03pm UTC](https://www.ruby-forum.com/t/activerecord-reducing-memory-footprint-with-find/126215/2 "2008-01-16T12:03:12Z")

</div>

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
