title: Fastest SQL 2005 select query for ASP .NET table paging?
body: <p>What is the fastest way to select a range of rows, let's say from 4.200.000 to 4.200.050, using SQL 2005? Suppose that I have 10 millions of rows.</p>
  
  <p>On my own projects I use the following approach, but I'm not sure if this is the best practice</p>
  
  <pre><code>select * from
  (
      select 
          Column1, Column2, Column3
          RowNumber = row_number() over (order by ID asc) 
      from 
          tblLogs
      where
          Column4 = @Column4 and Column5 = @Column5
      ) as tempTable
  where tempTable.RowNumber &gt;= @StartIndex and tempTable.RowNumber &lt;= @EndIndex
  </code></pre>
  
  <p>With the code above I am tempted to say that <strong>tempTable</strong> will be a big table with one column containing all my IDs.</p>
  
  <p>Is there anything faster ?</p>
  
  <p>Don't think to make some workarounds using the ID column, this won't work, I delete rows from that table, so my IDs are not successive numbers.</p>