title: How can I disable lazy loading of active record queries?
body: <p>I want to query some objects from the database using a WHERE clause similar to the following:</p>
  
  <pre><code>@monuments =  Monument.where("... lots of SQL ...").limit(6)
  </code></pre>
  
  <p>Later on, in my view I use methods like <code>@monuments.first</code>, then I loop through <code>@monuments</code>, then I display <code>@monuments.count</code>.</p>
  
  <p>When I look at the Rails console, I see that Rails queries the database multiple times, first with a limit of 1 (for <code>@monuments.first</code>), then with a limit of 6 (for looping through all of them), and finally it issues a count() query.</p>
  
  <p>How can I tell ActiveRecord to only execute the query once? Just executing the query once with a limit of 6 should be enough to get all the data I need. Since the query is slow (80ms), repeating it costs a lot of time.</p>