I have an SQL Server 2008 R2 database, and I have a table with a large number of rows, but only a few columns. The table currently has 84m records.
I'm looking for the most efficient way to query this table to get paged data sets. Really, I only need 30 records per page.
I can't use OFFSET
/FETCH
with this version of SQL Server. I also don't have admin access to change the table in any way.
The only other way I've found is using a sub query and ROW_NUMBER()
, but that seems to query the whole data set before returning a subset. This is very slow indeed.
What is the best (fastest) way to query this table for paged results..?