开发者

paging and performance

Q: I want to ask about :the paging.

is the paging feature in .net make any performance difference,i mean , sometimes开发者_StackOverflow社区 i have large data, if i wanna to bind these data on gridview for example ,is "paging" for example by count 10 , bring 10 records and 10 and so on or the same as if i don't use paging it brings all the data first and then viewing them according to the pager count.. if there is no relationship between paging and performance , what is the best practice in this case ?.


It depends how paging is implemented. Earlier versions of some server controls which handled paging, read the entire dataset into memory and then selected a subset of the available records. This is incredibly inefficient, as you've already incurred the transport cost of moving the data from your database, as well as the memory cost of storing it.

What you can do is perform the pagination at the database level, passing in the page number and the number of items to retrieve, and that way you're only reading the subset of the data at the source. It'll be much more performant. The only downside is that you may need to throw another query at the database to determine the total number of items so you can page properly. All in all, I think "paging at source" is always the preferred solution.


As far as I know, all ASP.NET Server Controls like DataGrid load the whole resultset and then just display one page. You would have to implement this yourself.

There is a discussion about this here: http://www.codeproject.com/KB/aspnet/PagingLarge.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜