SQL Server存储过程在网络集群中的表现更好吗?(Do SQL Server stored procedures perform better in network clusters?)

编程入门 行业动态 更新时间:2024-10-19 10:18:56
SQL Server存储过程在网络集群中的表现更好吗?(Do SQL Server stored procedures perform better in network clusters?)

从我读过的内容来看,使用存储过程似乎只是边缘性能优势,而不是简单地在C#中构建命令并在程序代码中明确地调用它们,至少在共享服务器程序和数据库引擎的机器上(和当程序很简单时)。 大多数人似乎认为这是一个“偏好问题”,并添加一些其他小的好处来证明他们的理由。

但是,当数据库引擎位于与主应用程序不同的物理机器上时,我无法找到任何信息,这是存储过程的好处。

如果我没有弄错,在服务器场中,存储过程是否会卸载来自主服务器应用程序的某些cpu线程上的处理,并且在db引擎服务器的cpu上完成主要处理? 或者,这是否已经在db引擎的cpu上完成,当C#库“构建”db引擎要处理的信息时?

具体来说,我有一个长时间运行的事务,我可以在C#事务块中进行多次调用,但我怀疑存储过程实际上会通过减少对数据库引擎的网络调用以及保证来获得巨大的性能优势。在主服务器应用程序上没有进行处理。

这是真的?

From what I've read, there appears to be marginal performance benefits using stored procedures vs simply building the commands in C# and calling them explicitly in the program's code, at least when it comes to machines that share the server program and db engine (and when the procedures are simple). Most people seem to think it's a 'preference issue', and add a few other minor benefits to justify their case.

However, one I couldn't find any information on, is the benefit of a stored procedure when the database engine is located on a separate physical machine from the main application.

If I am not mistaken, in a server farm, wouldn't a stored procedure offload the processing on some cpu threads from the main server application, and have the primary processing done on the db engine server's cpu instead? Or, is this already done on the db engine's cpu anyways, when the C# libraries 'build' the information for the db engine to process?

Specifically, I have a long-running transaction that I could do multiple calls in a C# transaction block, but I suspect that a stored proc will in fact have a huge performance benefit by reducing the network calls to the db engine, as well as guaranteeing the processing is not being done on the main server application.

Is this true?

最满意答案

存储过程的性能提升(与Dapper或OR / M之类的实体框架相比)可以从几乎相同的非常显着的性能改进变化。 如果没有看到将转换为存储过程的代码,我认为您的问题无法得到解答。

话虽如此,根据我的经验,使用应用程序代码进行单个存储过程调用与多个语句,是的,它可能会更快。

Performance gains from a stored procedure (versus something like Dapper or an OR/M like Entity Framework) can vary anywhere from nearly identical to a very noticeable performance improvement. I don't think your question can be answered without seeing the code that would be translated to a stored procedure.

Having said that, in my experience making a single stored procedure call versus multiple statements from the application code, yes, it would likely be faster.

更多推荐

本文发布于:2023-08-04 11:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415196.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:集群   存储过程   网络   Server   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!