# Delaying table attribute load using ActiveRecord

**URL:** <https://www.ruby-forum.com/t/delaying-table-attribute-load-using-activerecord/56588>\
**Category:** Engines Development\
**Created:** [April 1, 2006, 12:34pm UTC](https://www.ruby-forum.com/t/delaying-table-attribute-load-using-activerecord/56588 "2006-04-01T12:34:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![llecigne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@llecigne](https://www.ruby-forum.com/u/llecigne)\
**Post date:** [April 1, 2006, 12:34pm UTC](https://www.ruby-forum.com/t/delaying-table-attribute-load-using-activerecord/56588/1 "2006-04-01T12:34:59Z")

</div>

Hi all,

I came accross the following problem lately: I got a table with several  
BLOB fields (Oracle DB) and I have ActiveRecord reading those fields  
whenever records are loaded using finder methods. This behavior is just  
fine in 99.9% of the time, but considering BLOB data is not small, it is  
considerably slowing down search access :(.

So basically, I thought about building a :has\_one relationship and add  
an extra table table holding BLOB value so as to cope with the pb. I  
found it painfull and not very ‘RoRy’, so I decided to hack  
ActiveRecord::Base so as to delay the attribute load… and it works !  
Attributes are dynamicaly loaded whenever client application accesses  
them explicitely.

Syntax looks like the following:

class A \< ActiveRecord::Base  
delay\_attributes :foo, :bar  
…  
end

Now I got two questions:

- as I am new Rails (and Ruby as well): I am wondering if I am missing  
something concerning ActiveRecord usage (meaning this hack is useless),
- if this patch is a good idea, I’d like to submit it to the  
maintainers of the project, but I don’t know what is the exact procedure  
to do so.

Thx

---

<div class="post-metadata">

**Author:** ![llecigne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@llecigne](https://www.ruby-forum.com/u/llecigne)\
**Post date:** [April 1, 2006, 1:39pm UTC](https://www.ruby-forum.com/t/delaying-table-attribute-load-using-activerecord/56588/2 "2006-04-01T13:39:56Z")

</div>

This post is probably more suitable for the main rails list.

- james

On 4/1/06, Laurent L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> found it painfull and not very ‘RoRy’, so I decided to hack
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> engine-developers mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![llecigne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@llecigne](https://www.ruby-forum.com/u/llecigne)\
**Post date:** [April 2, 2006, 12:20pm UTC](https://www.ruby-forum.com/t/delaying-table-attribute-load-using-activerecord/56588/3 "2006-04-02T12:20:48Z")

</div>

Done.

Thx

James A. wrote:

> This post is probably more suitable for the main rails list.
> 
> - james
> 
> On 4/1/06, Laurent L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > found it painfull and not very ‘RoRy’, so I decided to hack
> > 
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > * * *
> > 
> > engine-developers mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org)
> 
> –
> 
> - J \*  
> ~
