Home > Uncategorized > .NET SQL Execution Plan

.NET SQL Execution Plan

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
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: