inner join Vs scalar Function

前端 未结 4 1969
太阳男子
太阳男子 2020-12-31 07:15

Which of the following query is better... This is just an example, there are numerous situations, where I want the user name to be displayed instead of UserID



        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 07:59

    The inline SQL JOIN will usually be better than the scalar UDF as it can be optimised better.

    When testing it though be sure to use SQL Profiler to view the cost of both versions. SET STATISTICS IO ON doesn't report the cost for scalar UDFs in its figures which would make the scalar UDF version appear better than it actually is.

提交回复
热议问题