I'm currently reading a book about SQL Server 2014. It claims that User-Defined Scalar Valued Functions prevent parallelism for the entire plan that they appear in. Is this still true in later versions?
I'm currently reading a book about SQL Server 2014. It claims that User-Defined Scalar Valued Functions prevent parallelism for the entire plan that they appear in. Is this still true in later versions?
1条答案
按热度按时间niknxzdl1#
If the function is not inlined it still prevents parallelism.
TSQLUserDefinedFunctionsNotParallelizable
still exists as aNonParallelPlanReason
in the execution plan for 2022.If the function is inlined the query can go parallel.
There is an example of that here
Here are some key observations from the above plan ... SQL Server is now using parallelism across all operators.
Scalar function inlining has been available since SQL Server 2019 but only some functions meet the criteria for this and there have been some issues with the implementation of the feature meaning that the criteria for what can be inlined has become more strict .
It is still the case that if a computed column in a table references a scalar UDF then this blocks paralellism - irrespective of whether or not the UDF can be inlined however.