Saturday, June 28, 2008

CodeProject: Paging of Large Resultsets in ASP.NET

Paging of Large Resultsets in ASP.NET - CodeProject
An article about optimization and performance testing of MS SQL Server 2000 stored procedures used for paging of large resultsets in ASP.NET

Download PagingTest Solution (C#) - 55.8 Kb
Download Paging_Procedures SQL script - 2.48 Kb
Download Paging_LargeTable SQL script - 0.6 Kb

The paging of a large database resultset in Web applications is a well known problem. In short, you don't want all the results from your query to be displayed on a single Web page, so some sort of paged display is more appropriate. While it was not an easy task in the old ASP, the DataGrid control in the ASP.NET simplifies this to a few lines of code. So, the paging is easy in ASP.NET, but the default behavior of the DataGrid is that all resulting records from your query will be fetched from SQL server to the ASP.NET application. If your query returns a million records this will cause some serious performance issues (if you need convincing, try executing such a query in your web application and see the memory consumption of the aspnet_wp.exe in the task manager). That's why a custom paging solution is required where desired behavior is to fetch only the rows from the current page.

No comments: