<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.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>Tips, Tricks, and Advice from the SQL Server Query Processing Team : Compilation time</title><link>http://blogs.msdn.com/sqlqueryprocessing/archive/tags/Compilation+time/default.aspx</link><description>Tags: Compilation time</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Compilation Time Issues in OLTP Applications When Upgrading to SQL 2005</title><link>http://blogs.msdn.com/sqlqueryprocessing/archive/2006/09/26/compilation-time-issues-in-oltp-applications-when-upgrading-to-sql-2005.aspx</link><pubDate>Wed, 27 Sep 2006 08:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:773291</guid><dc:creator>queryproc</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sqlqueryprocessing/comments/773291.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlqueryprocessing/commentrss.aspx?PostID=773291</wfw:commentRss><description>&lt;P&gt;&lt;FONT style="BACKGROUND-COLOR: #ffffff" face=Arial color=#000000 size=2&gt;I've helped a lot of people upgrade their SQL 2000 applications to SQL 2005.&amp;nbsp;&amp;nbsp;While many of these upgrades go well, occasionally some applications have issues and the overall workload may perform more poorly after the upgrade.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="BACKGROUND-COLOR: #ffffff" face=Arial color=#000000 size=2&gt;One area where I've seen issues is with ad-hoc on-line transaction processing (OLTP) systems.&amp;nbsp; This class of application performs a relatively large number of simple compilations.&amp;nbsp; Often, many of the resultant plans are almost identical and would never change - i.e. there's not many possible execution plans for these queries.&amp;nbsp;&amp;nbsp; While we make efforts to make sure that the upgrade experience is positive, major releases that take 5 years have a lot of variables that can change.&amp;nbsp; This can change the "sweet spot" for getting optimal performance out of an application.&lt;/FONT&gt;&lt;/P&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;Reasons things can perform differently after upgrading include:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;1.&amp;nbsp;SQL&amp;nbsp;Server 2005 performs more optimizations, and the fixed cost of doing those will go up a bit each release.&amp;nbsp; Generally this cost won't be very visible, but compilation-intensive scenarios may see some impact.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT color=#000000&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;/SPAN&gt;&lt;FONT color=#000000&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial size=2&gt;2. The code size of SQL 2005 &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial size=2&gt;is larger than SQL 2000 (it has more features).&amp;nbsp; The working set of these features is also larger in the new release.&amp;nbsp; This can cause additional L2 cache line misses on both code and data.&amp;nbsp; Some of the older x86 server machines (say, the 5-year-old machines you may have bought right when&amp;nbsp;SQL 2000 came out)&amp;nbsp;have relatively small L2 caches, and they may see lower cycles-per-instruction after upgrade.&amp;nbsp; This causes an application to run more slowly.&amp;nbsp; The newer x86 CPUs have larger L2 caches (2 MB)&amp;nbsp;and tend to do a lot better.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;3. Some internal&amp;nbsp;components and features&amp;nbsp;were rewritten in SQL 2005, and they may change the exact performance characteristics of an application that is upgraded.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;For ad-hoc OLTP applications, it's a combination of all of these.&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;FONT color=#000000&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial size=2&gt;The good news is that there's&amp;nbsp;a way to make many of these applications perform a lot better than even the SQL 2000 level - use parameterized queries.&amp;nbsp; These can reduce the overall number of compilations significantly, reducing the CPU and memory load on the system.&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=527184920-17082006&gt;&lt;/SPAN&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial size=2&gt;Generally speaking, if your application is an OLTP application and is not sensitive to plan choice for each query, forced parameterization can be a good way to manage any compilation slowdown.&amp;nbsp; However, please be sure (via testing) that your application is insensitive to query plan changes, as you can lose all (and more) of your compilation time gains via slower execution of sub-optimal plans.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial size=2&gt;&lt;FONT color=#000000&gt;Going forward, we recommend customers take opportunities to examine their stored procedures and other logic to make sure that you're using parameterized queries when necessary to reduce compilation time.&amp;nbsp; We expect that this will improve the overall system throughput for our customers (even compared to forced parameterization if done to completion).&amp;nbsp; I've written a fairly detailed blog entry on how to better understand the impact of parameters on plan quality here(&lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/queryoptteam/archive/2006/03/31/565991.aspx"&gt;&lt;FONT color=#000000&gt;http://blogs.msdn.com/queryoptteam/archive/2006/03/31/565991.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;FONT color=#000000&gt;), so I hope it can help you in tuning this application as well.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;I hope that this helps you when you are planning SQL 2000 to SQL 2005 upgrades.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT face=Arial color=#000000 size=2&gt;Conor Cunningham&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV dir=ltr align=left&gt;&lt;SPAN class=527184920-17082006&gt;&lt;FONT color=#000000&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=773291" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlqueryprocessing/archive/tags/SQL+Server+2005/default.aspx">SQL Server 2005</category><category domain="http://blogs.msdn.com/sqlqueryprocessing/archive/tags/Compilation+time/default.aspx">Compilation time</category><category domain="http://blogs.msdn.com/sqlqueryprocessing/archive/tags/OLTP/default.aspx">OLTP</category></item></channel></rss>