# Eager loading kills the :select clause in ActiveRecord

**URL:** <https://www.ruby-forum.com/t/eager-loading-kills-the-select-clause-in-activerecord/158975>\
**Category:** Rails\
**Created:** [January 29, 2009, 10:59pm UTC](https://www.ruby-forum.com/t/eager-loading-kills-the-select-clause-in-activerecord/158975 "2009-01-29T22:59:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [January 29, 2009, 10:59pm UTC](https://www.ruby-forum.com/t/eager-loading-kills-the-select-clause-in-activerecord/158975/1 "2009-01-29T22:59:41Z")

</div>

hi

I’ve dramatically improved my SQL performance with eager loading, but  
the problem is, it kills the :select directive because it generates  
its own (it ONLY selects the table fields and eager loaded table  
fields). Is there a way around this? I have some left outer joins in  
my :joins clause, and some aliasing in my :select clause, but  
the :include clause kills the select aliases. any advice?

thanks,  
dino

---

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [January 30, 2009, 12:59pm UTC](https://www.ruby-forum.com/t/eager-loading-kills-the-select-clause-in-activerecord/158975/2 "2009-01-30T12:59:01Z")

</div>

dino d. wrote:

> I’ve dramatically improved my SQL performance with eager loading, but  
> the problem is, it kills the :select directive because it generates  
> its own (it ONLY selects the table fields and eager loaded table  
> fields). Is there a way around this? I have some left outer joins in  
> my :joins clause, and some aliasing in my :select clause, but  
> the :include clause kills the select aliases. any advice?

Not supported at present, though I have a plugin that makes  
this work for Rails 2.0.2, not yet ported to 2.1+:

[http://dev.rubyonrails.org/ticket/7147#comment:12](http://dev.rubyonrails.org/ticket/7147#comment:12)

There is another plugin that works with 2.2 that allows you  
to load object hierarchies when using custom SQL:

[http://rubyforge.org/projects/eagerfindersql](http://rubyforge.org/projects/eagerfindersql)

–  
Rails Wheels - Find Plugins, List & Sell Plugins -  
[http://railswheels.com](http://railswheels.com)
