title: Efficient SQL to retrieve top results
body: <p>I have the following table:</p>
  
  <pre><code>id, first_name, last_name, score, feedback, report_date
  1,  Barry     , Smith    , 5    , positive, 2017-02-01
  2,  John      , Smith    , 6    , negative, 2017-02-01
  3,  Barry     , Smith    , 3    , negative, 2017-01-31
  5,  John      , Smith    , 1    , positive, 2017-01-31
  </code></pre>
  
  <p>I would like to retrieve the latest score and feedback for first and last name.</p>
  
  <p>I tried the following query:</p>
  
  <pre><code>select m.ad_id, m.country, m.score, m.feedback
  from records m
  inner join  (
     select first_name, last_name, max(report_date) as max_date
     from records
     where report_date &lt;= '2017-02-19 15:00:00'
       and report_date &gt;='2017-02-19 10:00:00'
       and score is not null
     GROUP BY first_name, last_name
     ) mp  on m.first_name = mp.first_name
           and m.last_name=mp.last_name
           and m.report_date = mp.max_date
           and m.report_date &lt;= '2017-02-19 15:00:00'
           and m.report_date&gt;='2017-02-19 10:00:00'
     ;
  </code></pre>
  
  <p>However, on 18M records it takes a few seconds.</p>
  
  <p>Making a simple query:</p>
  
  <pre><code>select m.fist_name, m.last_name, m.score, m.feedback
  from records m
  where m.report_date &lt;= '2017-02-19 15:00:00'
    and m.report_date&gt;='2017-02-19 10:00:00' 
    and score is not null
  </code></pre>
  
  <p>Taking less than half a second, however it would return x amount of records which takes more traffic.
  How can I make the first query more efficient?</p>