Ruby on Rails Thursday, December 16, 2010

> Please quote the previous message so individual messages in the thread
> make sense.

Sure, sorry.

> >> My approach is this way because I can't guarantee that there will be a
>> record with a certain date, yet I want to produce an array of results
>> for a full contiguous range of dates. In the case that there isn't a
>> record with a certain date, I still want to put in a 'placeholder value'
>> for that date in the array I'm creating.
>
> OK, I misunderstood. Going back to your original question then, you
> say:
>> I know how to do this by doing a new ActiveRecord find for each date in
>> my iteration range, but I don't want to do that as the overhead of so
>> many calls is too high.
>
> How do you know that the overhead is too high?

I've tried this approach, where I request each date in a range
individually, iterating over the range of dates I require. But the dates
may span 30-60 days or even more, and this causes ~60 separate sql
requests on the database. The result is a noticeable pause when loading
the page (backed up by benchmark figures), and a solution which doesn't
scale to larger ranges of dates.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment