title: Query on SQL Server Express is taking too long to execute
body: <p>I have two tables Channel and ChannelData. Channel Table has 40 records, every minute a record will be inserted in to ChannelData table for each Channel in the Channel Table. Now ChannelData table has more than 15 million records in it. I wrote a query as following to get the latest logged values for the 40 Channels in ChannelData Table.</p>
  
  <pre><code>select
      max(chnldata.Id) as ChannelDataId,
      chnl.id as ChannelId,
      chnl.ChannelName as ChannelName,
      chnldata.ChannelValue as channelValue,
      chnl.ChannelMonitoringUnits as ChannelUnits, 
      chnldata.ChannelDataLogTime as channelDataLogTime,
      chnl.StationId,
      chnldata.Active
  from
      ChannelData as chnldata                        
      inner join Channel as chnl on chnl.Id = chnldata.ChannelId 
  where
      chnl.Active = 1
      and
      chnldata.ChannelDataLogTime in 
          (SELECT
              MAX(chnldata1.ChannelDataLogTime)
           FROM
              ChannelData as chnldata1
           where 
              chnldata1.ChannelId = chnl.Id)                        
  group by
      chnldata.Id,
      chnl.id,
      ChannelName,
      ChannelValue,
      chnl.ChannelMonitoringUnits,
      ChannelDataLogTime,
      chnl.StationId,
      chnldata.Active
  </code></pre>
  
  <p>When I am executing this query on SQLServer 2008 Express Edition it is taking 29 minutes to get the results, but when i tried to run the same query on SQLServer 2008 Standard Edition it took less than 1 min on a database with ChannelData table of 15 million records. Is there any other way to write this query, so that I could get the results in less than a minute in SQL Server 2008 Express. </p>