I am currently watching this video on Entity Framework and about 15 minutes in, the speaker says that table value functions occasionally out perform UDF's.
My question is in what scenario do TVF's out perform UDF's?
|
I am currently watching this video on Entity Framework and about 15 minutes in, the speaker says that table value functions occasionally out perform UDF's. My question is in what scenario do TVF's out perform UDF's? |
|||||||||
|
Scalar UDF have uses, but not in this case. The performance difference can be huge: I've achived x100,000+ improvements by removing idiotic uses of UDFs |
|||
|
|
When do we need to call the function for every row - than in case of UDF it more looks like cursor loop - because it forces Sql Server to use single-threaded query plan. The TVF has no such restriction So, the answer is - if the query CAN be parallelized - then TVF outperforms the UDF |
||||
|
|