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! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hello Rob, Thank You Thank you Thank you for replying!! Sorry about my confusing writing. Here''s the improvement: So I have the FAST version like this: <html><body> <% for i in Recipes.find(:all) %> <%= i.ingredients %> <% end %> </body</html> All ingredients from the 5,000+ recipes show up in less than 1.5 seconds. Then I have this slow version like this: <html><body> <%= link_to_remote "show ingredients", :update => "targetdiv", :url => {:action => "showIngredients"} %> <div id="targetdiv"> </div> </body></html> and in the controller: def showingredients render :update do |page| page.replace_html ''targetdiv'', :partial => ''i'', :collection => Recipes.find(:all) end end And in the partial ''i'': <%= i.ingredients %> So that''s all. The slow version takes as much as 14 seconds sometimes. Any ideas? On Mar 29, 5:50 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> 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 > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 30, 2007, at 12:51 PM, Nik wrote:> Hello Rob, Thank You Thank you Thank you for replying!! > > Sorry about my confusing writing. Here''s the improvement: > > So I have the FAST version like this: > <html><body> > <% for i in Recipes.find(:all) %> > <%= i.ingredients %> > <% end %> > </body</html> > > All ingredients from the 5,000+ recipes show up in less than 1.5 > seconds. > > Then I have this slow version like this: > <html><body> > <%= link_to_remote "show ingredients", :update => "targetdiv", :url => > {:action => "showIngredients"} %> > <div id="targetdiv"> > </div> > </body></html> > > and in the controller: > def showingredients > render :update do |page| > page.replace_html ''targetdiv'', :partial => ''i'', :collection => > Recipes.find(:all) > end > end > > And in the partial ''i'': > <%= i.ingredients %> > > > > So that''s all. The slow version takes as much as 14 seconds sometimes. > > Any ideas?Have you looked at this with Firefox and Firebug? You should be able to see how long the request takes. Then I''d see what changing to: def showingredients render :update do |page| page.replace_html ''targetdiv'', :partial => ''i'', :collection => Recipes.find(:all, :limit => 10) end end does to the timing. Actually, do you even get the right result after you wait for it? You have :update => "targetdiv", but then you''re sending the javascript to do the replace. If you want to keep the :update, change the controller to be just: def showingredients render :partial => ''i'', :collection => Recipes.find(:all, :limit => 10) end Hope that helps. -Rob> On Mar 29, 5:50 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > wrote: >> 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 >> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.orgRob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey, So, are you saying that when you render the 5000 recipes using an ordinary browser request it''s fast, but when you try to use AJAX to update the page with 5000 recipes it''s much slower? Doesn''t that seem sensible? The AJAX response for stuff like page.replace_html will be escaped so that it can be evaluated by javascript (so it will be a larger over-the-wire transfer) *and* the javascript engine will have to process the response... Sounds to me like the solution is staring you in the face - don''t use AJAX in the situations where it''s faster to just render the whole page. HTH Trevor On 30-Mar-07, at 9:51 AM, Nik wrote:> > Hello Rob, Thank You Thank you Thank you for replying!! > > Sorry about my confusing writing. Here''s the improvement: > > So I have the FAST version like this: > <html><body> > <% for i in Recipes.find(:all) %> > <%= i.ingredients %> > <% end %> > </body</html> > > All ingredients from the 5,000+ recipes show up in less than 1.5 > seconds. > > Then I have this slow version like this: > <html><body> > <%= link_to_remote "show ingredients", :update => "targetdiv", :url => > {:action => "showIngredients"} %> > <div id="targetdiv"> > </div> > </body></html> > > and in the controller: > def showingredients > render :update do |page| > page.replace_html ''targetdiv'', :partial => ''i'', :collection => > Recipes.find(:all) > end > end > > And in the partial ''i'': > <%= i.ingredients %> > > > > So that''s all. The slow version takes as much as 14 seconds sometimes. > > Any ideas? > > On Mar 29, 5:50 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > wrote: >> 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 >> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Rob, thanks again for the swift reply. I did mean to take out the :update part. Sorry about the confusion (again). I tried the :limit => 10, but it doesn''t seem to help;( I am doomed. Nik On Mar 30, 10:10 am, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> On Mar 30, 2007, at 12:51 PM, Nik wrote: > > > > > Hello Rob, Thank You Thank you Thank you for replying!! > > > Sorry about my confusing writing. Here''s the improvement: > > > So I have the FAST version like this: > > <html><body> > > <% for i in Recipes.find(:all) %> > > <%= i.ingredients %> > > <% end %> > > </body</html> > > > All ingredients from the 5,000+ recipes show up in less than 1.5 > > seconds. > > > Then I have this slow version like this: > > <html><body> > > <%= link_to_remote "show ingredients", :update => "targetdiv", :url => > > {:action => "showIngredients"} %> > > <div id="targetdiv"> > > </div> > > </body></html> > > > and in the controller: > > def showingredients > > render :update do |page| > > page.replace_html ''targetdiv'', :partial => ''i'', :collection => > > Recipes.find(:all) > > end > > end > > > And in the partial ''i'': > > <%= i.ingredients %> > > > So that''s all. The slow version takes as much as 14 seconds sometimes. > > > Any ideas? > > Have you looked at this with Firefox and Firebug? You should be able > to see how long the request takes. Then I''d see what changing to: > > def showingredients > render :update do |page| > page.replace_html ''targetdiv'', :partial => ''i'', :collection => > Recipes.find(:all, :limit => 10) > end > end > > does to the timing. > > Actually, do you even get the right result after you wait for it? > You have :update => "targetdiv", but then you''re sending the > javascript to do the replace. If you want to keep the :update, > change the controller to be just: > > def showingredients > render :partial => ''i'', :collection => Recipes.find(:all, :limit > => 10) > end > > Hope that helps. > > -Rob > > > > > On Mar 29, 5:50 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > > wrote: > >> 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 > >> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > > Rob Biedenharn http://agileconsultingllc.com > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Trevor!, Thank You for commenting! I totally agree with you. Okay, here''s what I REALLY want to do, I have for instance, Chinese food, Italian food, and etc, right, these are menus on the left hand panel if you can imagine, and on the right- hand side is this targetdiv that will contain all the recipes when the "XYZ food" button is clicked. So I do want to make the targetdiv a rather dynamic thing, you know what I mean? I tried this RJS business. It failed (to achieve the speed) and I beat my brains out to try to speed it up. I guess I should just load all on the page and hide them until toggled? Nik On Mar 30, 10:16 am, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote:> Hey, > > So, are you saying that when you render the 5000 recipes using an > ordinary browser request it''s fast, but when you try to use AJAX to > update the page with 5000 recipes it''s much slower? > > Doesn''t that seem sensible? The AJAX response for stuff like > page.replace_html will be escaped so that it can be evaluated by > javascript (so it will be a larger over-the-wire transfer) *and* the > javascript engine will have to process the response... > > Sounds to me like the solution is staring you in the face - don''t use > AJAX in the situations where it''s faster to just render the whole page. > > HTH > Trevor > > On 30-Mar-07, at 9:51 AM, Nik wrote: > > > > > Hello Rob, Thank You Thank you Thank you for replying!! > > > Sorry about my confusing writing. Here''s the improvement: > > > So I have the FAST version like this: > > <html><body> > > <% for i in Recipes.find(:all) %> > > <%= i.ingredients %> > > <% end %> > > </body</html> > > > All ingredients from the 5,000+ recipes show up in less than 1.5 > > seconds. > > > Then I have this slow version like this: > > <html><body> > > <%= link_to_remote "show ingredients", :update => "targetdiv", :url => > > {:action => "showIngredients"} %> > > <div id="targetdiv"> > > </div> > > </body></html> > > > and in the controller: > > def showingredients > > render :update do |page| > > page.replace_html ''targetdiv'', :partial => ''i'', :collection => > > Recipes.find(:all) > > end > > end > > > And in the partial ''i'': > > <%= i.ingredients %> > > > So that''s all. The slow version takes as much as 14 seconds sometimes. > > > Any ideas? > > > On Mar 29, 5:50 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > > wrote: > >> 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 > >> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
May I add just one more thing I saw in the command prompt when loading the page using the fast and slow method: For the FAST method: it show only a few new lines For the slow method: it shows a few thousand lines of these: Rendered /recipe/_i <0.00100> ... Does that help? On Mar 30, 10:29 am, "Nik" <NiKS...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey Trevor!, Thank You for commenting! > > I totally agree with you. Okay, here''s what I REALLY want to do, I > have for instance, Chinese food, Italian food, and etc, right, these > are menus on the left hand panel if you can imagine, and on the right- > hand side is this targetdiv that will contain all the recipes when the > "XYZ food" button is clicked. So I do want to make the targetdiv a > rather dynamic thing, you know what I mean? I tried this RJS business. > It failed (to achieve the speed) and I beat my brains out to try to > speed it up. > > I guess I should just load all on the page and hide them until > toggled? > > Nik > > On Mar 30, 10:16 am, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote: > > > Hey, > > > So, are you saying that when you render the 5000 recipes using an > > ordinary browser request it''s fast, but when you try to use AJAX to > > update the page with 5000 recipes it''s much slower? > > > Doesn''t that seem sensible? The AJAX response for stuff like > > page.replace_html will be escaped so that it can be evaluated by > > javascript (so it will be a larger over-the-wire transfer) *and* the > > javascript engine will have to process the response... > > > Sounds to me like the solution is staring you in the face - don''t use > > AJAX in the situations where it''s faster to just render the whole page. > > > HTH > > Trevor > > > On 30-Mar-07, at 9:51 AM, Nik wrote: > > > > Hello Rob, Thank You Thank you Thank you for replying!! > > > > Sorry about my confusing writing. Here''s the improvement: > > > > So I have the FAST version like this: > > > <html><body> > > > <% for i in Recipes.find(:all) %> > > > <%= i.ingredients %> > > > <% end %> > > > </body</html> > > > > All ingredients from the 5,000+ recipes show up in less than 1.5 > > > seconds. > > > > Then I have this slow version like this: > > > <html><body> > > > <%= link_to_remote "show ingredients", :update => "targetdiv", :url => > > > {:action => "showIngredients"} %> > > > <div id="targetdiv"> > > > </div> > > > </body></html> > > > > and in the controller: > > > def showingredients > > > render :update do |page| > > > page.replace_html ''targetdiv'', :partial => ''i'', :collection => > > > Recipes.find(:all) > > > end > > > end > > > > And in the partial ''i'': > > > <%= i.ingredients %> > > > > So that''s all. The slow version takes as much as 14 seconds sometimes. > > > > Any ideas? > > > > On Mar 29, 5:50 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > > > wrote: > > >> 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 > > >> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Nik wrote:> May I add just one more thing I saw in the command prompt when loading > the page using the fast and slow method: > > For the FAST method: it show only a few new lines > For the slow method: it shows a few thousand lines of these: > Rendered /recipe/_i <0.00100> > ... > > Does that help?instead of doing page.replace_html ''targetdiv'', :partial => ''i'', :collection => Recipes.find(:all) try something like this: @recipes= Recipes.find(:all) page.replace_html ''targetdiv'', :partial => ''i'' then in your i partial, do for var in @recipes html that loops here end The issue is that ruby has to make 5000 template renders. If you do the loop in the view, its just 1 render. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Just for curiosity, what the hell will you do with 5000 recipes in ONE page ?? Use the limit option set to 20 at most, then use pagination and stuff to get more recipes... Lemme see the page with 5000 recipes, just wonder about the usability Regards matthi Nik schrieb:> 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! > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---