title: SQL query takes longer time when date range is smaller?
body: <p>I have a simple select statement which selects data from a SQL Server 2000 (so old) table with about 10-20 million rows like this - </p>
  
  <pre><code>@startDate = '2014-01-25' -- yyyy-mm-dd
  @endDate = '2014-02-20'
  
  SELECT 
      Id, 6-7 other columns
  FROM 
      Table1 as t1
  LEFT OUTER JOIN 
      Table2 as t2 ON t1.Code = t2.Code
  WHERE 
      t1.Id = 'G59' -- yes, its a varchar
      AND (t1.Entry_Date &gt;= @startDate AND t1.Entry_Date &lt; @endDate) 
  </code></pre>
  
  <p>This gives me about 40 K rows in about 10 seconds. But, if I set @startDate = '2014-01-30', keeping @endDate same ALWAYS, then the query takes about 2 min 30 sec </p>
  
  <p>To produce the same number of rows, I tried it with 01-30 again and it took 2 min 48 seconds.</p>
  
  <p>I am surprised to see the difference. I was not expecting the difference to be so big. Rather, I was expecting it to take the same time or lesser for a smaller date range. </p>
  
  <p>What could be the reason for this and how do I fix it ?</p>