title: Query takes too long to fetch data
body: <p>I am aware of the slow query log but isnt this just for queries that exceed the maximum execution time?  My question is slightly different (i think).</p>
  
  <p>I am running the below query and to me it doesnt seem like it should present a problem.  But when i run it, the "Running" time is over 20 seconds and then it sits there "Fetching" for ages!  To the point where i have to stop it due to DB performance issues.</p>
  
  <p>Can anyone explain where i am going wrong here.  Coding newbie so please be gentle.</p>
  
  <pre><code>SELECT 
  t1.oid,
  (SELECT 
          DATE_FORMAT(t2.date,
                      '%d/%m/%y') AS 'AVF Date'
      FROM
          t2
      WHERE
          t1.oid = t2.fk_oid
              AND t2.type = '-25'
              AND YEAR(t2.date) BETWEEN 2005 AND 2014
      ORDER BY t2.date ASC
      LIMIT 1) AS 'AVF Date',
  t2.site 
  FROM
  t1
  left join t2 on t1.oid=t2.fk_oid
  </code></pre>
  
  <p>UPDATE - Ok so what i need is as follows.  We have a patient database and these patients have procedures recorded on this database.  I am trying to return the patient oid (t1.oid) along with the FIRST procedure that they had (if it was between 2005 and 2014) and where they had it (t2.date and t2.site respectively), but only if the procedure is of a particular type (t2.type = '-25') </p>
  
  <p>So basically.  All the patients who had an AVF between 2005 and 2014 along with the "site" of the AVF (which in this case is left arm/right arm etc.)</p>
  
  <p>I hope this makes it a bit clearer.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Mikey</p>