Solved

SQL Execution Plan

Posted on 2011-10-01
4
321 Views
Last Modified: 2012-05-12
Is it possible to view the execution plan of a running stored procedure? We have an SP that used to run fairly in under 30 minutes (which was fine given the massive job it performed) but since partitioning was introduced to one of the tables last week, it takes over 6 hours to run.

I need a way to see the execution plan while the SP is running. Is this possible?

thanks,
Dean
0
Comment
Question by:dthansen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 36896609
If you are meaning while it is actually running, you may be talking about profiling it. However, you may be able to figure this out based on your knowledge of the system as you have a correlation with a recent change, i.e., if you introduced partitioning, I would look at what field you partitioned on in conjunction with the data you are querying. If your queries are having to ALWAYS span all the partitions, then the benefits of partitioning may be lost and actually a huge overhead as you are seeing.

This might be a good read:
http://blogs.technet.com/b/josebda/archive/2009/03/19/sql-server-2008-partitioning.aspx
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 500 total points
ID: 36896613
Assuming the procedure runs periodically as a job, first disable this job.

Then open a new query in Management Studio, and on the menu select Query / Show Actual Execution Plan

Then run the procedure manually in this window:

  exec  my_spname  [params]

Then you can view the execution plan of the running procedure (or the actual plan after it runs).

Don't forget to re-enable the job after this!  :)
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 36896898
In the strict sense the answer to your question is no.  But it is more involved than just looking at the execution plan even if it was available while running.  If as I suspect the Stored Procedure is complex with multiple queries you need to do identify the query or queries that are taking a long time.  This can and should be done while running with something like Adam Machanic's sp_WhoIsActive script.  But in order to do this you may need a baseline of what it used be like and I am not sure if this is available to you.
0
 
LVL 18

Expert Comment

by:lludden
ID: 36899581
Your SP may be trying to use an old execution plan.  Try using /RECOMPILE on it and see if that fixes the problem.
0

Featured Post

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to solve "recursive" database tables 2 59
sql, how to change the data type after data loading? 9 59
SQL query 45 41
learning MS SSIS 13 22
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question