# Partial data load on :include

**URL:** <https://www.ruby-forum.com/t/partial-data-load-on-include/116795>\
**Category:** Rails\
**Created:** [October 9, 2007, 9:15pm UTC](https://www.ruby-forum.com/t/partial-data-load-on-include/116795 "2007-10-09T21:15:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shredluc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@shredluc](https://www.ruby-forum.com/u/shredluc)\
**Post date:** [October 9, 2007, 9:15pm UTC](https://www.ruby-forum.com/t/partial-data-load-on-include/116795/1 "2007-10-09T21:15:25Z")

</div>

Hello everyone,

I am working on a support tool. I have two models, one called Service  
and another called Issues. A service may have many issues. I then  
output tables showing what services have what issues. When creating  
the tables i only need partial data out of the Service and Issues  
tables. So in other words for each service i want to preload the  
issues, but only the data i need to use. Otherwise the include takes  
over 20 seconds to load. If i could specify which columns to preload,  
it would only load a tenth of the data. Will the rails framework  
force me to break up the issues table into two? Does anyone have a  
solution?

Thanks,

Norbert

---

<div class="post-metadata">

**Author:** ![shredluc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@shredluc](https://www.ruby-forum.com/u/shredluc)\
**Post date:** [October 10, 2007, 3:06pm UTC](https://www.ruby-forum.com/t/partial-data-load-on-include/116795/2 "2007-10-10T15:06:37Z")

</div>

On 10/9/07, shredluc [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> it would only load a tenth of the data. Will the rails framework  
> force me to break up the issues table into two? Does anyone have a  
> solution?

Two ideas:

1. use find\_by\_sql and roll your own query that pulls just what you  
need for the report.

2. create a view in the database that selects a subset of columns from  
issues, and then define an AR model over that view that you can  
associate to services.

---

<div class="post-metadata">

**Author:** ![shredluc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@shredluc](https://www.ruby-forum.com/u/shredluc)\
**Post date:** [October 11, 2007, 5:47am UTC](https://www.ruby-forum.com/t/partial-data-load-on-include/116795/3 "2007-10-11T05:47:02Z")

</div>

shredluc wrote:

> tables. So in other words for each service i want to preload the  
> issues, but only the data i need to use. Otherwise the include takes  
> over 20 seconds to load. If i could specify which columns to preload,  
> it would only load a tenth of the data. Will the rails framework  
> force me to break up the issues table into two? Does anyone have a  
> solution?

There are several solutions at [http://dev.rubyonrails.org/ticket/7147](http://dev.rubyonrails.org/ticket/7147)

I use [http://dev.rubyonrails.org/ticket/7147#comment:12](http://dev.rubyonrails.org/ticket/7147#comment:12) as a plugin.  
Warning: experimental, WFM.

–  
We develop, watch us RoR, in numbers too big to ignore.
