SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Execution Plan Incomplete


Execution Plan Incomplete

Author
Message
TUellner
TUellner
SSC-Addicted
SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)

Group: General Forum Members
Points: 423 Visits: 1274
I'm trying to show a developer how to rewrite a stored procedure. It's a pretty scary SP (hundreds of lines of T-SQL in a cursor loop doing a bunch of selects - all to create a dynamic SQL statement). I know we're all cringing in horror at this point but what I wanted to do was show him just how bad the performance would be and what it would do to SQL Server by walking him through the execution plan. When I include the actual execution plan, the SP that normally runs about 6 - 10 seconds now runs for over a minute (which I presume is the time spent generating the plan). The problem comes from the plan not finishing. I scrolled through this and when I got to the end of the plan screen, it was cut off half way through a query.

The question is - Is there a way to display the entire plan? Any switches or tricks for getting the entire plan to display?

Thanks
Tom
Erland Sommarskog
Erland Sommarskog
SSCertifiable
SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)

Group: General Forum Members
Points: 5424 Visits: 875
Why on Earth would you want to see the execution plan for that horrible procedure? When you have a loop, there will be plan for execution of a statement, and SSMS is likely to choke. (Which is one reason why it taking such long time to run. There is an overhead for creating the XML as well.)

If you want to show the developer how bad the procedeure is, the current behaviour does serve as threating example, but I'm not sure that the developer will get the drift anyway.

Erland Sommarskog, SQL Server MVP, www.sommarskog.se
GilaMonster
GilaMonster
SSC Guru
SSC Guru (231K reputation)SSC Guru (231K reputation)SSC Guru (231K reputation)SSC Guru (231K reputation)SSC Guru (231K reputation)SSC Guru (231K reputation)SSC Guru (231K reputation)SSC Guru (231K reputation)

Group: General Forum Members
Points: 231552 Visits: 46352
TUellner (7/16/2013)
(which I presume is the time spent generating the plan).


That's the time spend by SSMS rendering the plan, before it runs out of memory (or hits max resultsets) and gives up.
There's no good reason to display a plan of a procedure like that, you can't really demonstrate much from a plan of a cursor, just lots and lots and lots of repetition of the same piece of the plan.

Maybe use performance characteristics to teach this lesson and show him exec plans of something simpler?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


TUellner
TUellner
SSC-Addicted
SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)

Group: General Forum Members
Points: 423 Visits: 1274
Thanks all. I know it's not useful for anything other than a teaching tool. I was hoping to get to the execution of the dynamic SQL mess at the end just out of savage curiosity.

-Tom
HowardW
HowardW
SSCertifiable
SSCertifiable (6.6K reputation)SSCertifiable (6.6K reputation)SSCertifiable (6.6K reputation)SSCertifiable (6.6K reputation)SSCertifiable (6.6K reputation)SSCertifiable (6.6K reputation)SSCertifiable (6.6K reputation)SSCertifiable (6.6K reputation)

Group: General Forum Members
Points: 6571 Visits: 9892
TUellner (7/16/2013)
Thanks all. I know it's not useful for anything other than a teaching tool. I was hoping to get to the execution of the dynamic SQL mess at the end just out of savage curiosity.

-Tom


Well that's a lot easier. Just change the exec/sp_executesql at the bottom of the SQL to a print, run the loop without generating plans and copy the SQL at the bottom to run in isolation.
TUellner
TUellner
SSC-Addicted
SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)SSC-Addicted (423 reputation)

Group: General Forum Members
Points: 423 Visits: 1274
Thanks Howard. I should have thought of that. Appreciate the help.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search