# Concerns on gathering a large query

**URL:** <https://www.ruby-forum.com/t/concerns-on-gathering-a-large-query/141596>\
**Category:** Rails\
**Created:** [June 27, 2008, 2:24pm UTC](https://www.ruby-forum.com/t/concerns-on-gathering-a-large-query/141596 "2008-06-27T14:24:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottc12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71c47a/32.png) [@scottc12](https://www.ruby-forum.com/u/scottc12)\
**Post date:** [June 27, 2008, 2:24pm UTC](https://www.ruby-forum.com/t/concerns-on-gathering-a-large-query/141596/1 "2008-06-27T14:24:38Z")

</div>

Question - When a large sql query is run and it returns to a @results  
array how large can this be? Is there a better method of storing this  
info? I can limit the Browsers display with Pagination but I’m  
concerned on the Array storing.

My current query is a date range query. If you select a large enough  
value the returned result could be very large and over time it will  
continue to grow for sure. What other ways can a large query be  
handled in ROR?

Thanks  
Sc-

---

<div class="post-metadata">

**Author:** ![scottc12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71c47a/32.png) [@scottc12](https://www.ruby-forum.com/u/scottc12)\
**Post date:** [June 27, 2008, 2:33pm UTC](https://www.ruby-forum.com/t/concerns-on-gathering-a-large-query/141596/2 "2008-06-27T14:33:28Z")

</div>

On 27 Jun 2008, at 13:21, scottc12 wrote:

> Question - When a large sql query is run and it returns to a @results  
> array how large can this be? Is there a better method of storing this  
> info? I can limit the Browsers display with Pagination but I’m  
> concerned on the Array storing.

‘How long is a piece of string?’. I don’t think there is a hard limit  
other than memory, but you’ll probably hit usability limits before (eg  
a page showing 10,000 rows of data would be horrible to use). If  
you’re doing your pagination right, at any point you will only have  
the data for the current page in memory.

Fred

---

<div class="post-metadata">

**Author:** ![scottc12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71c47a/32.png) [@scottc12](https://www.ruby-forum.com/u/scottc12)\
**Post date:** [June 27, 2008, 2:37pm UTC](https://www.ruby-forum.com/t/concerns-on-gathering-a-large-query/141596/3 "2008-06-27T14:37:34Z")

</div>

Thanks Frederick – Super quick response. So far I have enabled my page  
view  
results to be 50 , toss up a warning on the collected results total and  
its  
working. But the array itself still contains the entire set correct?sc  
On Fri, Jun 27, 2008 at 8:32 AM, Frederick C. \<  
removed\_email\_address@domain.invalid\> wrote:

> ‘How long is a piece of string?’. I don’t think there is a hard limit
> 
> > continue to grow for sure. What other ways can a large query be  
> > handled in ROR?
> > 
> > Thanks  
> > Sc-
> > 
> > >
> 
> >

–  
Scott Comboni  
President  
Zenplex Inc.  
132 Pepes Farm Road Unit #6  
Milford CT, 06460

---

<div class="post-metadata">

**Author:** ![scottc12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71c47a/32.png) [@scottc12](https://www.ruby-forum.com/u/scottc12)\
**Post date:** [June 27, 2008, 2:51pm UTC](https://www.ruby-forum.com/t/concerns-on-gathering-a-large-query/141596/4 "2008-06-27T14:51:03Z")

</div>

On 27 Jun 2008, at 13:36, Scott Comboni wrote:

> Thanks Frederick – Super quick response. So far I have enabled my  
> page view results to be 50 , toss up a warning on the collected  
> results total and its working. But the array itself still contains  
> the entire set correct?  
> It depends on what you’re doing. I certainly wouldn’t load the whole  
> collection only to use 50 of them. Things like will\_paginate will get  
> this right for you

Fred

---

<div class="post-metadata">

**Author:** ![scottc12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71c47a/32.png) [@scottc12](https://www.ruby-forum.com/u/scottc12)\
**Post date:** [June 27, 2008, 2:59pm UTC](https://www.ruby-forum.com/t/concerns-on-gathering-a-large-query/141596/5 "2008-06-27T14:59:51Z")

</div>

Thanks again – Thats exactly what I’m using. I just watched a  
railscast on Endless pagination. Very nice indeed.

Sc-

On Jun 27, 8:50 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![scottc12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71c47a/32.png) [@scottc12](https://www.ruby-forum.com/u/scottc12)\
**Post date:** [June 27, 2008, 4:28pm UTC](https://www.ruby-forum.com/t/concerns-on-gathering-a-large-query/141596/6 "2008-06-27T16:28:21Z")

</div>

You can limit the rows returned by changingf the find(:all) in the  
controller to a more appropriate number of records.
