title: Query takes too long to run
body: <p>I am running the below query to retrive the unique latest result based on a date field within a same table. But this query takes too much time when the table is growing. Any suggestion to improve this is welcome.</p>
  
  <pre><code>select
      t2.*
  from
      (
          select
              (
                  select
                      id
                  from
                      ctc_pre_assets ti
                  where
                      ti.ctcassettag = t1.ctcassettag
                  order by
                      ti.createddate desc limit 1
              ) lid
          from
              (
                  select
                      distinct ctcassettag
                  from
                      ctc_pre_assets
              ) t1
      ) ro,
      ctc_pre_assets t2
  where
      t2.id = ro.lid
  order by
      id
  </code></pre>
  
  <p>Our able may contain same row multiple times, but each row with different time stamp. My object is based on a single column for example assettag I want to retrieve single row for each assettag with latest timestamp.</p>