Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'll agree with everyone else. You have to profile. There is no point in doing anything to your code until you know what specifically is causing the slowness. Trying to fixing a problem without understanding the cause is like feeling ill and deciding to have lots of surgery until you feel better. Diagnose your problem first. It might be something small like a network setting or it could be one bad line in your code. </p> <p>Some tips for profiling:</p> <p><a href="http://cfis.savagexi.com/2007/07/10/how-to-profile-your-rails-application" rel="noreferrer">How to Profile Your Rails Application</a></p> <p><a href="http://guides.rubyonrails.org/performance_testing.html" rel="noreferrer">Performance Testing Rails Applications</a></p> <p><a href="http://www.linuxjournal.com/article/10128" rel="noreferrer">At the Forge - Profiling Rails Applications</a></p> <p>Once you have found the bottleneck you can figure out what to do.</p> <p>I recommend these videos: <a href="http://railslab.newrelic.com/scaling-rails" rel="noreferrer">Railslab Scaling Rails</a></p> <p>Revised now based on prof results:</p> <p>OK. Now that you can see that your problem is that you are doing some sort of calculation using a query based on looping through the results of another active record query I'd advise you to look into building a custom SQL statement combining your initial selection criteria and the loop calculation to get what you need. You can definitely speed this up by optimizing the SQL.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload