Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Improve GridView and Object Data Source Performance
Message
De
27/07/2006 10:13:22
 
 
À
27/07/2006 05:30:10
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01140604
Message ID:
01140678
Vues:
70
This message has been marked as the solution to the initial question of the thread.
>My page has a GridView, which display the data from a table. The table has about 50000 records. The GridView data source is an object data source, which retrieves data from the table. I set the page size of the GridView to 10. The GridView takes more than 10 seconds to load the records. May I know how to make the data retrieval faster?

GridView/ObjectDataSource by default will use "default paging" which means that ALL records matching the query will be brought at one time to the code and then the controls will decide which records to display and which to discard. This is probably how you have it set up and why your performance is so slow.

The better approach is "custom paging" -- you code your business object / data retrieval object(s) to accept parameters for page index and maximum rows per page and then point ObjectDataSource to that Select method. You then configure some properties on ObjectDataSource to tell it the names of those parameters in your method call. ODS and GridView can then get just the records needed from the database for each paging call.

The trick is coding your data access routines to efficiently pull just a subset from somewhere inside the query results. If using SQL Server 2005, the new ROW_NUMBER function can be very useful. Otherwise, you have to pull into a temp table inside a stored procedure and then select out of that subset.

You'll find complete explanations here (I found this just by Googling "paging gridview performance"):

http://aspnet.4guysfromrolla.com/articles/031506-1.aspx
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform