What is the best paging method with datagrid performance?

On a site with a large number of users, it is necessary for the paging to be handled by code or stored procedure. If you've used caching, list the success factors.

+1


source to share


5 answers


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.

+2


source


Personally, I will never forget anything outside of SQL Server. I do it at the database level, as if you have a million records to dump, if you download them at the application level and put it there, you are already paying a huge cost .



+3


source


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.

+3


source


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.

+1


source


I think it depends on the number of records to be dumped. For example, you have 100 posts to be uploaded. I think it doesn't require SQL paging stuff to do this. I always try to stick to the KISS principle and premature optimization.

0


source







All Articles