performance difference between User Defined Function and Stored Procedures

后端 未结 6 996
终归单人心
终归单人心 2021-01-08 00:28

If a statement return rows doing a simple select over the data base, is there performance difference between implement it using Function and Procedures? I know it is prefera

6条回答
  •  庸人自扰
    2021-01-08 01:00

    As soon as SQL sees a BEGIN or END, the system cannot simplify the contents out.

    So really the difference just comes down to thd fact that the results of a function can be used in an outer query, for joins, ignoring some columns and so on.

    Your best bet is actually to use either a view or an inline table-valued function, so that SQL can simplify it down and only do the part that you're interested in. Look for my post on "Dangers of BEGIN and END" at my blog for more info.

提交回复
热议问题