简体   繁体   English

如何通过许多数据库请求来加快大型网页的速度?

[英]How can I speed up large web page with many DB requests?

Platform: Asp.Net (Website),C#, SQL Server 2012, Ajax. 平台:Asp.Net(网站),C#,SQL Server 2012,Ajax。

I am developing an Asp.Net web application It will be used by many users (may be around 5000 or more). 我正在开发一个Asp.Net Web应用程序,它将被许多用户使用(可能大约有5000个或更多)。 Where I have a webpage on which I display around 200 to 500 Grid Rows, each row contains around 20 to 25 controls like TextBox, Dropdown, Link Button & some HTML links to show/Hide information using JavaScript. 当我有一个网页显示大约200到500个网格行时,每行包含大约20到25个控件,例如TextBox,Dropdown,Link Button和一些HTML链接,以使用JavaScript显示/隐藏信息。

It's basically a data-entry page where user can edit/add records & finally save them. 基本上,这是一个数据输入页面,用户可以在其中编辑/添加记录并最终保存它们。

I reloads the HTML on each Page load (as I have set the View State to false for this Literal Control). 我在每次页面加载时都重新加载HTML(因为我已将此文字控件的“查看状态”设置为false)。 On Server side execution it generally takes 5 to 8 seconds, but it generally loads whole content in 12 to 18 seconds, but some times it takes around 40 seconds to over 1 minute (I guess this could be the concurrency issue but not sure as many times with some users it loads in 15 seconds approx.). 在服务器端执行通常需要5到8秒,但通常需要12到18秒才能加载整个内容,但是有时大约需要40秒到1分钟以上(我想这可能是并发问题,但不确定那么多时间(某些用户需要加载大约15秒)。

What I do for loading this HTML? 我要如何加载此HTML?

1st I fetch the list of combined items from DB, then I break it into hierarchy view, then I loop through each item & creates the HTML string. 首先,我从数据库中获取组合项目的列表,然后将其分解为层次结构视图,然后遍历每个项目并创建HTML字符串。 In each Items there are many sub Items like Getting Staff List to de displayed in DDL, also getting Distance for each Staff, etc (again I hit DB for each sub processing). 在每个项目中,有许多子项目,例如在DDL中显示要获取的工作人员列表,还获取每个工作人员的距离等(同样,我在每个子处理中都点击了DB)。

Some of these operations include very large DB Tables(having more than 50,000 rows) I have tune such stored procedures to avoid any use of like/Replace/etc operators. 其中一些操作包括非常大的DB表(具有50,000多行),我已经调整了此类存储过程,以避免使用like / Replace / etc运算符。

Please guide me what approach should be taken in such a scenario? 请指导我在这种情况下应采取什么方法? Can I use Threads to perform multiple operations in Web Applications to reduce the processing time? 我可以使用线程在Web应用程序中执行多项操作以减少处理时间吗?

Thanks 谢谢

This seems like a big page with a lot of functionality. 这似乎是一个包含许多功能的大页面。 How do you manage your edits? 您如何管理您的编辑? Do you allow users to do multiple changes to multiple rows and then commit or do you commit to the server after each row edit? 您是允许用户对多行进行多次更改然后提交还是在每次行编辑后提交给服务器?

I think that you could employ JavaScript and maybe leverage modern HTML5 features like local data etc to allow your users to edit and see the data locally cached on the page and then use JavaScript to push the updated data back to the server. 我认为您可以使用JavaScript ,还可以利用本地数据等现代HTML5功能来允许您的用户编辑和查看页面上本地缓存的数据,然后使用JavaScript将更新后的数据推送回服务器。 By using Ajax you can push selectively only the updated data instead of a full page refresh through postback. 通过使用Ajax,您可以有选择地仅推送更新的数据,而不是通过回发推送整个页面。 That way your users get a better experience and you minimize the amount of data going back and forth the server. 这样,您的用户可以获得更好的体验,并且可以最大程度地减少往返服务器的数据量。

I hope this points you to the right direction. 我希望这可以为您指明正确的方向。

I would suggest to limit number of rows per page to 20-30 as you have mentioned you are displaying 200 to 500 Grid Rows. 我建议将每页的行数限制为20-30,因为您已经提到要显示200至500的网格行。 Also create separate page for edit instead of inline edit in grid where there are 20 to 25 controls are available to edit because it will increase page size as number of rows increase. 还可以在单​​独的页面中创建要编辑的页面,而不是在网格中进行内联编辑,因为在网格中可以编辑20到25个控件,因为随着行数的增加,页面大小也会增加。

I think, you haven't find answer on your question here. 我认为,您尚未在此处找到问题的答案。 Rather, there are common approaches for resolving this issue. 相反,有解决此问题的常用方法。

I think it is: 我觉得是这样的:

  • -ajax -ajax
  • -paging (separete your data result by pages) -分页(按页分隔数据结果)
  • -data caching 数据缓存
  • -creating summary view for current row (basic data set) with the possibility of other data-loading -为当前行(基本数据集)创建摘要视图,并可能加载其他数据

It's first things that comes to my head. 这是我想到的第一件事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM