并行访问 SQL Server
我正在尝试使用任务并行库从 UI 线程卸载昂贵的 ADO.NET 数据库访问(以前我正在重写的程序只会冻结,偶尔更新 VB6 文本框及其进度,直到数据库中的数据已完全加载)。我有一个复杂的依赖结构(26 个单独的任务),我试图弄清楚其中有多少值得并行化。
我想知道这样的 IO 访问是否可以并行化并带来性能奖励。如果不是,我将只顺序加载数据,并在加载足够的信息来执行该任务时更新 UI,但是通过一次加载两件事而不是仅仅一件来获得额外的提升会很好(即使我没有得到双倍加速)。
I'm trying to use the Task-Parallel-Library to offload expensive ADO.NET database access from the UI thread (formerly the program I'm re-writing would simply freeze, occasionally updating a VB6 text box with its progress, until the data in the database was fully loaded). I have an complex dependency structure (26 individual tasks), and I'm trying to figure out how much of it is worth parallelizing.
I'd like to know whether or not IO access like this can be parallelized at all with performance bonuses. If not I'll just sequentially load the data and update the UI whenever enough information is loaded to perform that task, but It'd be nice to get an extra boost by loading maybe two things at a time instead of just one (even if I don't get double speedup).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
并行化可能会提高性能,但不能保证。这完全取决于你的瓶颈在哪里。
例如,如果请求由于加载大量数据而成本高昂,那么它可能会消耗大量客户端网络带宽。在这种情况下,并行化并没有多大帮助(如果有的话)。
另一方面,如果瓶颈是 SQL 处理并且您的 SQL 请求使 SQL Server 在其自身的瓶颈中留下空闲容量,那么您可以从 SQL Server(非常好的)并行功能中获益。
并行化也可能会减慢你的速度。例如,如果 SQl Server 没有太多 RAM 并且只能访问单个磁盘,则强制它并行执行多个查询可能会导致硬盘上出现更多的查找活动,从而显着降低总体读取速率。
因此,正如通常的情况一样,答案不是简单的是或否,而是“视情况而定”。
It's possible that parallelizing this will increase performance, but not guaranteed. It all depends on where your bottleneck is.
For example, if a request is expensive because it loads lots of data, then it probably consumes much of your clients network bandwith. Parallelizing in this case wouldn't help much, if at all.
If, on the other hand, the bottleneck is the SQL processing and your SQL request leaves the SQL Server with spare capacity in its own bottleneck, then you can profit from SQL Servers (very good) parallelizing capabilities.
It is also possible that parallelizing slows you down. If for example the SQl Server has not much RAM and access only to a single disk, forcing it to do multiple queries in parallel may lead to more seek activity on the harddisk, which can dramatically slow down the overall read rate.
So, as it often is, the answer isn't a simple yes or no, but "it depends".