为什么.NET Sql Server 访问比 Excel Interop 更快?
这可能是一个沉重的问题,它可能会被否决,但这让我完全沮丧。
当您在开发中使用 SQL Server 时,数据访问快速且高效,但当您使用 COM 与 Excel 对话时,速度就非常慢。
无论您使用哪种数据访问技术,ADO、ADO.NET、LINQ、实体框架、Astoria(ADO.NET 数据服务),它们都比自动化 Excel 更快。
如果您想要的只是工作簿中单元格“A1”中的数据,则需要 Excel.Application、Excel.Workbook、Excel.Worksheet 和 Excel.Range 对象,只是为了获取一个数据点。
WTF,为什么与 SQL Server 对话比与 Excel 对话更有效? Excel 是本地的,而 Sql Server 可能不是。
TIA 克里斯
This might be a loaded question, and it might get voted down, but it completely frustrates me.
When you use SQL Server in your development the data access is fast and efficient, but when you use COM to talk to Excel it is piggy slow.
It doesn't matter what data access technology you use, ADO, ADO.NET, LINQ, Entity Framework, Astoria (ADO.NET Data Services), they are all quicker than automating Excel.
If all you want is the data in cell "A1" from a Workbook, you need an Excel.Application, Excel.Workbook, Excel.Worksheet, and Excel.Range objects, just to get one data point.
WTF, Why is talking to SQL Server more efficient than talking to Excel? Excel is local and Sql Server may not be.
TIA
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
因为启动一个设计为交互式应用程序的大型整体可执行文件比通过快速网络与为此目的而设计的应用程序进行通信要慢。
Because spinning up a big monolithic executable that was designed as an interactive application is slower than talking over a fast network to an application that was designed for the purpose.
每次需要与 Excel 对话时,服务器都必须实际启动 Excel 程序。它位于隐藏桌面中,但仍在启动整个程序。如果有多个人使用该网站,那么这也是 Excel 的多个实例。如果他们共享同一本工作簿,情况会更糟。
目前,Sql Server已经在运行。只需连接即可开始。它是为这种事情而建造的。 Excel 则不然。
Every time you need to talk to excel, the server has to actually start up the excel program. It's in a hidden desktop, but it's still starting up the entire program. If you have several people using the site, that's also several instances of Excel. And if they're sharing the same workbook it's even worse.
Sql Server, on the hand, is already running. Just connect and go. It was built for this kind of thing. Excel wasn't.
即使在 2007 年,Excel 仍然是一个 com 互操作性。但有很多帮助器
excel-performance-new-whitepaper-available
spreadsheetgear
excelpackage.codeplex
Excel is still a com interop, even in 2007. but there is many helpers
excel-performance-new-whitepaper-available
spreadsheetgear
excelpackage.codeplex
这是因为 SQL Server 是为服务器数据而设计的,而 Excel 不是。在您从 SQL Server 检索 1000 甚至数百万行之前,网络延迟根本不会发挥作用
This is becuase SQL server is designed to server data, Excel is not. Network latency won't even come into play here until you are retreiving 1000's maybe even millions of rows from SQL server