What is the best paging method with datagrid performance?
I would do it at the database level. Speaking of sql server 2005, I would use the new ROW_NUMBER () function by looking at: SQL Server 2005 paging results
Where typical sql would be:
SELECT Row_Number() OVER(ORDER BY UserName) As RowID, UserFirstName, UserLastName
FROM Users
WHERE RowID Between 0 AND 9
Here http://aspnet.4guysfromrolla.com/articles/031506-1.aspx you can see how it works and explore Scott Mitchell's little reference point.
source to share
99.9% of the time, paging should be done on the database server. However, this does not require stored procedures, and in fact, many stored procedure solutions depend on cursors and are rather inefficient. Ideally, use a single SQL statement tailored to your database platform to get the records you want and no more.
source to share
Most database vendors offer rich support for database paging. Use him; -p Note that this does not need to be a stored procedure (I will keep an eye on the ubiquitous command line attendant with saved-proc vs ad-hoc).
As an aside, many frameworks will do this effectively for you as well. For example, in .NET 3.5 (with LINQ) you can use Skip()
, and Take()
swap, which is used in the db.
source to share