Archive

Archive for the ‘Uncategorized’ Category

.NET SQL Execution Plan

15 October 2011 Leave a comment

Today at work we ran into a bit of a problem.  The page on our website kept timing out although the SQL that was causing the timeout executed in under a second.  After some Googling it turned out that SQL Server sometimes selects a different execution plan for .NET than for SQL Server Management Studio.  I found a SQL command that would return the execution plan that was chosen for the query and return it as a separate result set.

SET STATISTICS PROFILE ON;
-- Your Query
SET STATISTICS PROFILE OFF;

Since it was all text based and not that straight forward to understand I could not wait to get home and make it a bit more UI using Google Charts.  After hacking away for a couple of hours I ended up with an app that does just that.  The screenshot below is how the results now get displayed.

 

The source is uploaded to Github should anyone be interested in having a look at the source or possibly have a use for it somewhere.

Advertisements