Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

UDFs vs Performance

$
0
0

My question concerns UDFs versus performance. I'm specifically referring to in-line use of UDFs. As far as I know, I have read that UDFs should be avoided where possible due to performance issues. My understanding is that Scalar valued UDFs are called as many times as the number of rows which the query will be pulling when used in-line. Besides, I understand that UDFs are not precompiled by the engine if used in a stored procedure. 

My question relates to what happens exactly during run time. What I mean is about the number of times a UDF is called. Someone today mentioned to me something which they called "deterministic" behaviour of the engine. They said that if the engine calls a value it keeps it in memory so that the next time the same value is called the engine does not fetch it from the table but just takes it from the memory. In a way, the engine caches the values. To be honest, I'm not sure about this in the case of in-line UDFs. If this is how things happen under the hood – can this then be the argument for using in-line UDFs from a performance view point? Personally, I try to avoid using UDFs. The queries that I build are for data warehousing and therefore pull large amounts of rows per given run. I was just wondering if my fears of performance impact by in-line UDFs are real or not.

Many thanks,


Mpumelelo


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>