在ASP.NET或SQL中缓存记录 [英] Caching of records in asp.net or sql
问题描述
大家好,
我需要在sql或asp.net中使用某种缓存机制来存储从sql存储过程中检索到的数据(记录)..
实际情况:
我在sql中有一个存储过程,该存储过程可获取7个表并给出结果,获得的结果太大,即大约有5000条记录..
现在,我在asp.net gridview控件中显示该记录,这需要很长时间才能绑定该记录并将其显示在屏幕上
现在,当我插入一些记录(假设有10条记录)时,它将再次执行该存储过程并获取5010条记录,然后将其绑定到gridview控件
请提出一些我可以减少执行时间的方法,这种执行时间发生在获取记录和在前端显示记录....
我需要某种方式来存储5000条记录,当插入10条记录时,它仅获取10条记录,而这10条记录将追加到这5000条记录中...
请提出建议...
问候,
Krunal Panchal
Hello everyone,
I need some kind of caching mechanism in sql or in asp.net for storing data (records) retrieved from sql stored procedure..
Actual scenario :
I have one stored procedure in sql which fetches 7 tables and gives the result , the result obtained is too huge i.e. around 5000 records..
Now i display that records in asp.net gridview control which takes too long time to bind that record and display it on screen
Now when i insert some record suppose say 10 records, it will again execute that storedprocedure and fetch 5010 records and then will get bind to the gridview control
Please suggest something by which i could reduce this execution time which occurs in fetching record and displaying record in front end....
I need some way that i could store 5000 records and when 10 records are inserted , it fetches only 10 records and these 10 records are appended to those 5000 records...
Please suggest...
Regards,
Krunal Panchal
推荐答案
您真正想做的是实现一个不错的分页解决方案.这将解决您的两个问题,绑定时间不会很慢,并且通过缓存大量数据不会占用大量服务器内存.
人类无法一次处理5000条记录,这是太多信息.意见各不相同,但对于网格数据,我认为每页25至50行是正确的-对于眼睛可以读取和理解的内容.因此,如果您一次只显示此数量的记录,则只需要从数据库中获取该数量的记录即可.当您单击下一页"时,网格可以发出ajax请求并获取要显示的下一组数据.
这是使用更新面板 http://www的GridView示例. c-sharpcorner.com/uploadfile/prathore/gridview-paging-and-sorting-using-ajax/ [
What you really want to do is implement a decent paging solution. This will solve both your problems, you won''t have slow binding times and you won''t use lots of server memory by caching larges amounts of data.
Humans can''t handle 5000 records at once, it''s too much information. Opinions vary, but for grid data I think 25-50 rows per page is about right - for what the eye can read and comprehend. So, if you''re only displaying this amount of records at any one time, you only need to fetch that amount from your database. As you click ''next page'', your grid can make an ajax request and fetch the next set of data to display.
Here''s a GridView example using Update Panels http://www.c-sharpcorner.com/uploadfile/prathore/gridview-paging-and-sorting-using-ajax/[^], but I strongly suggest you spend a bit of time searching - that''s quite a basic example.
Using this technique, we have grids that happily display thousands of records.
您将喜欢此功能:SqlCacheDependency.
http://msdn.microsoft.com/en-us/library/9dz445ks.aspx [ ^ ]
使用SqlDependency进行数据更改事件 [
You will love this feature: SqlCacheDependency.
http://msdn.microsoft.com/en-us/library/9dz445ks.aspx[^]
Using SqlDependency for data change events[^]
Hope it helps
您可以使用SQL分页技术.
请检查以下URL:
http://shrikantlandge.blogspot.com/2009/05/pagination-with- mssql-server-2005.html [ ^ ]
You can use SQL paginiation techniq.
PLease check below URL :
http://shrikantlandge.blogspot.com/2009/05/pagination-with-mssql-server-2005.html[^]
这篇关于在ASP.NET或SQL中缓存记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!