I know several ways of writing paged query in SQL Server 2005. But I have no idea about their performance. Which one is the best and most optimized way for writing paging SQL queries?
- Using Row_Number()
- Using Partition by
- Using Temporary tables
- Using Nest Top N with Order by
- Some other way?
In my experience it’s using ROW_NUMBER(), just make sure the orderby field is the clustered index so you won’t have to pay penalties for sorting the dataset on each query.