使用 varchar(max) 参数的 SQL 性能
我在 SQL 存储过程中有两个 varchar(max) 参数。 其中之一是用 C# 生成的可读字符串,提供给用户以显示特定记录的哪些值已更改。 另一个是字符串的 XML 表示形式,我正在对其进行解析并将每个修改值的记录添加到数据库表中。
长话短说,可读字符串包含用户可以识别的数据库列的用户友好值;而 XML 表示形式包含数据库表的字段/列名称,如数据库设计视图中所示。
将两个 varchar(max) 参数传递给 SQL 存储过程是否会对性能造成影响?
如果是这样,仅传递 varchar(max) 参数之一并设置一个用户定义函数来解析该参数并创建用户友好的值以显示给用户是否有益?我担心会对用户定义函数进行多次调用,从而导致性能下降。
想法?
谢谢! 生锈的
I have two varchar(max) parameters in a SQL Stored Procedure.
One of which is a readable string generated in C# that is provided to the user to display what values for a particular record have changed.
The other, is an XML representation of the string, which I am parsing through and adding to a DB Table a record for each of the Modified values.
To make a long explanation short, the readable string contains user friendly values of the DB columns that the user can recognize; while the XML representation contains the DB Table's Field/Column Name as it appears in the DB design view.
Is there a performance hit in passing the two varchar(max) parameters to the SQL Stored Procedure?
If so, would it be beneficial to pass only one of the varchar(max) parameter and setup a User-Define-Function that will parse through the parameter and create the user friendly values to display to the user? I'm concerned that there will be multiple calls to the User-Defined-Function, resulting in a performance hit.
Thoughts?
Thanks!
Rusty
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否有理由相信传递两个参数比仅传递一个参数慢?
我怀疑传递单个参数并用 UDF 将其分解会更快,而且如果不这样做,增加的复杂性将很难证明是合理的。
Have you any reason to believe that passing through the two parameters is slower than passing through just one?
I'd doubt that passing through a single parameter and having it torn apart by a UDF would be any faster, and the added complexity would be hard to justify if not.