Search results matching tags 'Database Administration' and 'Plan Explorer'http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&tag=Database+Administration,Plan+Explorer&orTags=0Search results matching tags 'Database Administration' and 'Plan Explorer'en-USCommunityServer 2.1 SP2 (Build: 61129.1)Making Use of Plan Explorer in my own Environmenthttp://sqlblog.com/blogs/jonathan_kehayias/archive/2011/02/02/making-use-of-plan-explorer-in-my-own-environment.aspxThu, 03 Feb 2011 03:50:47 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:33141jmkehayias<p>Back in October 2010, I briefly blogged about the <a href="http://sqlsentry.com/plan-explorer/sql-server-query-view.asp" target="_blank">SQL Sentry Plan Explorer</a> in my <a href="http://sqlblog.com/blogs/jonathan_kehayias/archive/2010/10/04/sqlbits-7-wrap-up.aspx" target="_blank">blog post wrap up for SQL Bits 7</a> and how impressed I was with what I saw from a Alpha demo standpoint from Greg Gonzalez (<a href="http://greg.blogs.sqlsentry.net/" target="_blank">Blog</a>|<a href="http://twitter.com/sqlsensei" target="_blank">Twitter</a>) while I was at SQLBits 7 in York.&#160; To be 100% honest and transparent, Greg gave me early access to this tool after discussing it at SQLBits 7, and I had the opportunity to test a number of pre-Beta releases where I was able to offer significant feedback and submit bugs in the tool to Greg and the primary developer of the tool with SQL Sentry before Greg ever announced the public beta of the tool on his blog.&#160; </p> <p>Today I had the opportunity to work with a vendor of mine on a performance problem and during the investigation of the problems, I identified a query that if rewritten a different way, without any index changes impact to the SQL Server was significantly lower.&#160; To show this to the vendor I got on a WebEx session and shared my desktop with the vendors developers and executed their original query and my rewritten version of the query to show that my version output the same result and had significantly less impact to the server than their original one did.&#160; They could see this in the execution times of the two queries, but to really drive the point home I did a copy/paste of the Actual Execution Plan XML from the SQL Batch that contained both statements in it to the SQL Plan Explorer for the vendor.&#160; The output from SQL Plan Explorer is shown below.</p> <p><a href="http://sqlblog.com/blogs/jonathan_kehayias/image_109115CC.png" target="_blank"><img style="border-bottom:0px;border-left:0px;display:block;float:none;margin-left:auto;border-top:0px;margin-right:auto;border-right:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jonathan_kehayias/image_thumb_59973792.png" width="644" height="102" /></a> </p> <p>The highlighted statement above shows the impact of the vendors original statement, while the one below it shows the impact of the query rewrite that I did while tuning this statement.&#160; The rewrite that I did reduced the query execution time from 24 seconds to 4 seconds with the exact same output.&#160; After doing some indexing analysis and adding two indexes to the database for this regularly executed query, the execution time was under 300ms, and the vendor is looking at making changes to their database to accommodate these changes.&#160; However, the real win here was that the tool provided me with a way to show the two queries to the vendor to show their impact directly to the SQL Server.&#160; Funny enough, the vendor developers had never actually heard of this tool, and downloaded it while we were on a conference call today to give it a whirl.</p> <p>So how exactly did I do this?&#160; It is really much easier than you might think.&#160; To do this kind of side by side analysis, all you have to do is open a new query window in SQL Server Management Studio and paste both of the queries into the window.&#160; Then turn on the Include Actual Execution Plan from the toolbar button as shown below:</p> <p><a href="http://sqlblog.com/blogs/jonathan_kehayias/image_4173CD37.png" target="_blank"><img style="border-bottom:0px;border-left:0px;display:block;float:none;margin-left:auto;border-top:0px;margin-right:auto;border-right:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jonathan_kehayias/image_thumb_7AF6DD2E.png" width="272" height="28" /></a></p> <p>When you execute the Batch, both of the plans will be output in the Execution Plan, and then you can click on the Execution Plan tab to view the Execution Plans together in SQL Server Management Studio.&#160; To capture this and bring it into the SQL Sentry Plan Explorer, you can right click on the execution plan in SQL Server Management Studio and select the option to Show Execution Plan XML, which will open the Execution Plan in XML format in Management Studio.</p> <p><a href="http://sqlblog.com/blogs/jonathan_kehayias/image_7B631023.png"><img style="border-bottom:0px;border-left:0px;display:block;float:none;margin-left:auto;border-top:0px;margin-right:auto;border-right:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jonathan_kehayias/image_thumb_34E6201B.png" width="192" height="223" /></a>&#160;</p> <p>One of the best features of the SQL Sentry Plan Explorer is that you can paste the Execution Plan XML into the tool to get a different perspective of the information contained in the XML from SQL Server Management Studio.&#160; In the interests of protecting this vendor and their application, primarily because I value my job and I actually have a lot of respect for this vendor because they have been really amicable to work with over the last six months, I am going to mask any identifying information the example screenshots provided in the remainder of this blog post.&#160; The following is what SQL Server Management Studio presents for the Actual Execution Plans of the two queries:</p> <p><a href="http://sqlblog.com/blogs/jonathan_kehayias/image_6E693012.png" target="_blank"><img style="border-bottom:0px;border-left:0px;display:block;float:none;margin-left:auto;border-top:0px;margin-right:auto;border-right:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jonathan_kehayias/image_thumb_24BA5822.png" width="644" height="337" /></a> </p> <p>and here is the SQL Sentry Plan Explorer display for the two queries:</p> <p><a href="http://sqlblog.com/blogs/jonathan_kehayias/image_5862C480.png" target="_blank"><img style="border-bottom:0px;border-left:0px;display:block;float:none;margin-left:auto;border-top:0px;margin-right:auto;border-right:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jonathan_kehayias/image_thumb_4117C00F.png" width="644" height="368" /></a> </p> <p>Note that the graphical execution plan only shows one of the statements from the batch, the selected statement in the upper part of the window.&#160; Also note that the upper window shows the difference between the two statements that exist in the batch.&#160; Now previously I stated that I showed the vendor the output from the Actual Execution Plan, but if you note in the above, the output only shows the Estimated Execution Plan information.&#160; Unfortunately, at the point that I wrote this blog post, I didn’t have the Actual Execution Plan information available, and I couldn’t subject my production systems to the execution of these statements to write this blog post so I have had to use Estimated Plans that were edited to write this post.</p> <p>In this post I have shown just one of the many benefits that is offered by the SQL Sentry Plan Explorer to production support DBA’s.&#160; In my next few posts I will highlight a number of the other features of this free tool that a production support DBA will find useful in their regular work.</p>