Re: Slow performance

Rob Biedenharn
Fri, 30 Mar 2007 00:50:09 -0000

On Mar 29, 2007, at 8:16 PM, Nik wrote:
> Hello all, I found a strange dilemma here:
>
> I have a table of several thousand rows and I experimented with these
> two method to display them:
>
> In this first method, I just put the follow in the view, let''s
call
> the view, display.rhtml
> <% for x in Cookbook.find(:all) %>
> <%= x.recipe %>
> <% end %>
> The page displays all 5000 recipes in less than 2 seconds. I am quite
> happy with it.
>
> The second method, I put the find() business in the controller within
> a render :update do |page|.
>
> def showrecipe
>    render :update do |page|
>      page.replace_html ''displaydiv'', :partial =>
''recipe'', :collection
> => find(:all, conditions => ["cuisine = ?",
"italian"])
>  end
> end
>
> This method, when called, takes forever.
>
> ----> Can anyone be kind enough to hint why this is the case? <--
>
> Thank You!

Hmm... no index on the `cuisine` column?  (I''m assuming that you
really have :conditions as the : seems to be misssing.)

Also, do you really want to push that much data back with rjs?  If
all you need is to update a div, use the :update option on your
link_to_remote.

You also don''t say where the "forever" is taking place, for
example,
what does the log file contain?  (I don''t actually believe you since
I''m never personally waited that long ;-)

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org