Yes, if you have a lot of users, then you are loading all of your users X
2,700 (number of PO records).

As to Matt's comments, look into using something like @po_renewals =
PoRenewal.include([:cost_center, <other ar relationsihps...etc....>]) in
the controller action to avoid n+1 queries.  If you are not sure what that
is, google n+1 queries.  But the short answer is that you can avoid that in
ActiveRecord by using the includes method.
http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations

In the bigger picture, there are lots of other things you could do to make
this page more enjoyable.  Maybe some pagination would prevent having to
load 2700 records, each into a form row ?  Or does each pw_renewal record
need to be included in some batch form ?  Maybe some AJAX here could help
simplify things ?  I'm just guessing, because I really don't know the
requirements for your app.

Good luck!


On Wed, Mar 13, 2013 at 12:07 PM, Matt Aimonetti <[email protected]>wrote:

> No it's not normal and part of the issue is that you generate too many db
> requests from the view (n+x queries).
>
> I'm in a cell phone so I can't currently go into too many details but I'm
> sure someone else will or I will myself later today
> On Mar 13, 2013 12:02 PM, "KT" <[email protected]> wrote:
>
>> Hi all - can anyone tell me what I'm doing so wrong that it takes 7-9
>> minutes to load this form view?
>>
>>
>> https://github.com/sdstoic/vits/blob/master/app/views/po_renewals/index.html.erb
>>
>> The table holds about 2700 records, and has many columns, but still...
>> should it take that long?
>>
>> Ruby 1.9.3 / Rails 3.0.3
>> Apache / Passenger / MySQL
>>
>> Thanks in advance for any help.
>> Katie
>>
>> --
>> --
>> SD Ruby mailing list
>> [email protected]
>> http://groups.google.com/group/sdruby
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "SD Ruby" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>  --
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby
> ---
> You received this message because you are subscribed to the Google Groups
> "SD Ruby" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
--- 
You received this message because you are subscribed to the Google Groups "SD 
Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to