title: Rails - speed and time
body: <p>I have a question about the "speed of logic" between MVC.<br>
  Suppose to have the same code, something like the follow, in a model, in a view and in a controller.  </p>
  
  <p>1) The speed for "compiling" the logic and the query is the same in all three (M-V-C)?</p>
  
  <p>Pseudocode</p>
  
  <pre><code>x = model.where(:a &gt; 3, b &lt; 9).a.first
  y = model.sum(:a)
  z = (x / y) * 2310.0
  Date.today - 5
  </code></pre>
  
  <p>This is a "stupid" pseudocode, but I want to know the performance of line of code most used by my app (calling a <code>where</code> query, calling a <code>sum</code> (aggregate) query, do some math, playing with date)</p>
  
  <p>The problem, is that my pages are a bit so slowly to load. I have deplaced all that manage queries in the <code>Models</code> and add indexes. Maybe adding the caching can solve a little the problem (but I use Highcharts that I think can't be cached).</p>
  
  <p>2) How can I find where is the code bottleneck (that slow the loading of pages)?  </p>