title: how can I include association.count in ActiveRecord query so that it doesn't perform a second query?
body: <p>In my models I frequently have has_many associations. I also frequently need to display how many there are (i.e. assoc.count). This forces another query to be performed, as demonstrated below:</p>
  
  <pre><code>ruby-1.8.7-p334 :020 &gt; Instructor.first.instructors_lessons.count
    Instructor Load (0.5ms)  SELECT `users`.* FROM `users` INNER JOIN `instructor_profiles` ON `instructor_profiles`.`instructor_id` = `users`.`id` LIMIT 1
    SQL (1.2ms)  SELECT COUNT(*) FROM `instructors_lessons` WHERE (`instructors_lessons`.instructor_id = 2817)
  </code></pre>
  
  <p>This is fine when there is one or two, but when there is 100+, this process gets noticeably slow. 
  Please see this egregiously slow process (http://pastebin.com/p4Sj7q7s). I've been working around one very slow page with caching.</p>
  
  <p>I can put this in the query like so: but this is tedious and kind of defeats the purpose of ActiveRecord associations I feel:</p>
  
  <pre><code> select("instructors.*, count('instructors_lessons.instructor_id') as num_lessons").
  </code></pre>
  
  <p>But then I can't simply say instructor.lessons.count...</p>
  
  <p>Is there a way to use joins() or includes() so that this extra COUNT() query doesn't need to be performed?</p>