<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>T-SQL User-Defined Functions: the good, the bad, and the ugly (part 4)</title><link>http://sqlblog.com/blogs/hugo_kornelis/archive/2012/08/25/t-sql-user-defined-functions-the-good-the-bad-and-the-ugly-part-4.aspx</link><description>Scalar user-defined functions are bad for performance. I already showed that for T-SQL scalar user-defined functions without and with data access, and for most CLR scalar user-defined functions without data access , and in this blog post I will show that</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: T-SQL User-Defined Functions: the good, the bad, and the ugly (part 4)</title><link>http://sqlblog.com/blogs/hugo_kornelis/archive/2012/08/25/t-sql-user-defined-functions-the-good-the-bad-and-the-ugly-part-4.aspx#44861</link><pubDate>Fri, 24 Aug 2012 22:08:35 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44861</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Hugo, I wish you would have written to me before publishing so I could help you get that loopback code working. You need to do the loopback call in a different thread -- which is why I built the threading library (doing that work properly, so that you don't cause problems for yourself down the road, is not trivial).&lt;/p&gt;
</description></item><item><title>re: T-SQL User-Defined Functions: the good, the bad, and the ugly (part 4)</title><link>http://sqlblog.com/blogs/hugo_kornelis/archive/2012/08/25/t-sql-user-defined-functions-the-good-the-bad-and-the-ugly-part-4.aspx#44863</link><pubDate>Sun, 26 Aug 2012 02:03:20 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44863</guid><dc:creator>AlexK</dc:creator><description>&lt;p&gt;Hi Hugo,&lt;/p&gt;
&lt;p&gt;Typically we get better performance with ContainsKey method instead of catching exceptions, as you did in your TripleCache class. What do you think? &lt;/p&gt;
</description></item><item><title>re: T-SQL User-Defined Functions: the good, the bad, and the ugly (part 4)</title><link>http://sqlblog.com/blogs/hugo_kornelis/archive/2012/08/25/t-sql-user-defined-functions-the-good-the-bad-and-the-ugly-part-4.aspx#44864</link><pubDate>Sun, 26 Aug 2012 08:50:10 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44864</guid><dc:creator>Hugo Kornelis</dc:creator><description>&lt;p&gt;@Adam: Yup, I got that. And I did look at trying to implement the threading library. But after seeing the code and the supplied demos, I realised that for me (with my limited understanding of CLR), it would take a lot of time to get to understand it sufficiently before I could adapt it to work as part of a scalar UDF. And I did not want to postpone publishing this post even more, it was already delayed more than I wanted.&lt;/p&gt;
&lt;p&gt;@Alex: As I said before, I am absolutely not an expert in CLR. I wrote the code by adapting a snippet I found (somewhere in the MSDN library) through Google. I was not aware that it's possible to use ContainsKey instead of Try Catch. But now that I do, I'll have to play around with it and see how it affects performance. Thanks for the suggestion!&lt;/p&gt;
</description></item><item><title>re: T-SQL User-Defined Functions: the good, the bad, and the ugly (part 4)</title><link>http://sqlblog.com/blogs/hugo_kornelis/archive/2012/08/25/t-sql-user-defined-functions-the-good-the-bad-and-the-ugly-part-4.aspx#44865</link><pubDate>Sun, 26 Aug 2012 12:56:42 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44865</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;@Alex: I think that should only improve performance if you have a large number of &amp;quot;misses&amp;quot; (i.e. lookups for keys that don't exist). But shouldn't TryGetValue be best in every case?&lt;/p&gt;
</description></item><item><title>re: T-SQL User-Defined Functions: the good, the bad, and the ugly (part 4)</title><link>http://sqlblog.com/blogs/hugo_kornelis/archive/2012/08/25/t-sql-user-defined-functions-the-good-the-bad-and-the-ugly-part-4.aspx#44869</link><pubDate>Sun, 26 Aug 2012 19:26:17 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44869</guid><dc:creator>AlexK</dc:creator><description>&lt;p&gt;@Adam: the cache is the slowest when it is just warming up. This is when it needs speeding up most, and this is exactly when we have most misses.&lt;/p&gt;
&lt;p&gt;I agree that TryGetValue might be a very good choice. However, I would expect big difference between throwing exceptions and avoiding them, and somewhat smaller differences between different ways of avoiding exceptions. &lt;/p&gt;
&lt;p&gt;I have not benchmarked it recently, so I could be wrong.&lt;/p&gt;
&lt;p&gt;What do you think?&lt;/p&gt;
</description></item><item><title>re: T-SQL User-Defined Functions: the good, the bad, and the ugly (part 4)</title><link>http://sqlblog.com/blogs/hugo_kornelis/archive/2012/08/25/t-sql-user-defined-functions-the-good-the-bad-and-the-ugly-part-4.aspx#44870</link><pubDate>Sun, 26 Aug 2012 21:17:15 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44870</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;@Alex: Depends on how you design the cache. A lazy loading cache might get a lot of misses at the beginning; a more ambitious pre-loading scheme may avoid that. If it's possible to do. It all depends...&lt;/p&gt;
</description></item><item><title>re: T-SQL User-Defined Functions: the good, the bad, and the ugly (part 4)</title><link>http://sqlblog.com/blogs/hugo_kornelis/archive/2012/08/25/t-sql-user-defined-functions-the-good-the-bad-and-the-ugly-part-4.aspx#46875</link><pubDate>Fri, 28 Dec 2012 17:35:54 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:46875</guid><dc:creator>Danny Cordell</dc:creator><description>&lt;p&gt;I am looking forward to the article on table-valued UDF's.&lt;/p&gt;
</description></item><item><title>re: T-SQL User-Defined Functions: the good, the bad, and the ugly (part 4)</title><link>http://sqlblog.com/blogs/hugo_kornelis/archive/2012/08/25/t-sql-user-defined-functions-the-good-the-bad-and-the-ugly-part-4.aspx#47086</link><pubDate>Wed, 09 Jan 2013 15:52:39 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47086</guid><dc:creator>JP</dc:creator><description>&lt;p&gt;Are you still planning a fifth part to the series? This has been a great summary on the pros and cons of user defined functions.&lt;/p&gt;
</description></item><item><title>re: T-SQL User-Defined Functions: the good, the bad, and the ugly (part 4)</title><link>http://sqlblog.com/blogs/hugo_kornelis/archive/2012/08/25/t-sql-user-defined-functions-the-good-the-bad-and-the-ugly-part-4.aspx#47097</link><pubDate>Thu, 10 Jan 2013 09:47:16 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47097</guid><dc:creator>Hugo Kornelis</dc:creator><description>&lt;p&gt;JP: I definitely want to continue the series. But I cannot commit myself to any time frame at this time. I am now working on something else that takes up almost all the time I have available for community work.&lt;/p&gt;
&lt;p&gt;Once that is done, I hope to find enough time and energy to resume my blogging.&lt;/p&gt;
</description></item></channel></rss>