title: Django: MySQL queries run really slowly, but are fast when run directly against database (not through Django)
body: <p>I'm building a Django app with some pretty straightforward queries. When I run it locally the performance is pretty poor: DebugToolbar reports <code>4119.00 ms (6 queries)</code> which is obviously pretty bad. The longest-running query is this one:</p>
  
  <p>Django <code>views.py</code> code:</p>
  
  <pre><code>reviews = list(Review.objects.select_related('band', 'record', 'label').order_by('-date_posted')[:12])
  </code></pre>
  
  <p>Outputted SQL:</p>
  
  <pre><code>SELECT * FROM `reviews` 
  INNER JOIN `bands` ON (`reviews`.`band_id` = `bands`.`id`) 
  INNER JOIN `records` ON (`reviews`.`record_id` = `records`.`id`) 
  INNER JOIN `label` ON (`reviews`.`label_id` = `label`.`id`) 
  ORDER BY `reviews`.`date_posted` DESC 
  LIMIT 12
  </code></pre>
  
  <p>Now obviously there's a few joins there, but my tables are properly indexed. When I run that query in phpMyAdmin I get <code>Query took 0.0241 sec</code>, but in DebugToolbar I see <code>1838.00 ms</code>. The other 5 queries are similarly sluggish, but run normally when queried directly.</p>
  
  <p>I'm running Django on Windows and using MySQL (WAMP server). Can anyone think of any reason why Django's own queries could be so slow? </p>