且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server性能ResultSet vs输出参数vs返回值

更新时间:2023-02-17 13:59:48

返回标量值比结果集更有效,原因是结果集包含更多的辅助方法,这使它繁重,从而增加了延迟将对象从sql传输到C#代码/例程.

Returning a scalar value is more efficient than a result set, the reason is result set carries lot more helper methods along with it, which makes it heavy thus increasing latency in transmission of the object from sql to C# code/routine.

在方法3中:您使用了变量来返回值,这比发送out参数要好,因为在这里,您减少了一条路线上对象的遍历最少(即,调用存储过程时) .

In your method 3: You have used a variable to return the value this is more better than sending an out parameter since here you are cutting down on traverse of an object atleast in one route ( i.e., when invoking the stored procedure).

结果集比输出参数更灵活,因为它可以返回多行(显然),因此,如果您需要结果集,那么它是唯一的选择.

A result set is more flexible than an output parameter because it can return multiple rows (obviously), so if you need a result set then it's the only choice anyway.

要根据方法3,方法2和方法1的性能对查询进行排序.

To order the queries based on performance that goes as Method 3, Method 2 Method 1.

希望这有助于理解概念.

Hope this is helpful in understanding the concept.