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


multiple execution plans - not sure why?


multiple execution plans - not sure why?

Author
Message
curious_sqldba
curious_sqldba
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2978 Visits: 3637
I have a stored procedure which runs 1000+ times a day. I can see that every time it is creating a new execution plan. I took the stored procedure ,opened two sessions in ssms and executed the sproc. I do see it is creating two new plans.
One thing different about this sproc is it is inserting data into a temp table which is created by another sproc. Any thoughts on how to avoid this? Could this be parameter sniffing?
DBA_Dom
DBA_Dom
Say Hey Kid
Say Hey Kid (680 reputation)Say Hey Kid (680 reputation)Say Hey Kid (680 reputation)Say Hey Kid (680 reputation)Say Hey Kid (680 reputation)Say Hey Kid (680 reputation)Say Hey Kid (680 reputation)Say Hey Kid (680 reputation)

Group: General Forum Members
Points: 680 Visits: 81110
Can you provide some more information about what your procedures are doing. Code would be helpful. Are you using dynamic SQL? What is the Server Advance setting for Optimize for Ad hoc Workloads set to? What is the Database option for Parameterization set to?
GilaMonster
GilaMonster
SSC Guru
SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)

Group: General Forum Members
Points: 89469 Visits: 45284
sqldba_newbie (3/29/2013)
I can see that every time it is creating a new execution plan. I took the stored procedure ,opened two sessions in ssms and executed the sproc. I do see it is creating two new plans.


How are you seeing that?

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


curious_sqldba
curious_sqldba
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2978 Visits: 3637
DBA_Dom (3/29/2013)
Can you provide some more information about what your procedures are doing. Code would be helpful. Are you using dynamic SQL? What is the Server Advance setting for Optimize for Ad hoc Workloads set to? What is the Database option for Parameterization set to?


Not adhooc, this is executed from the app.
curious_sqldba
curious_sqldba
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2978 Visits: 3637
GilaMonster (3/29/2013)
sqldba_newbie (3/29/2013)
I can see that every time it is creating a new execution plan. I took the stored procedure ,opened two sessions in ssms and executed the sproc. I do see it is creating two new plans.


How are you seeing that?


Couple different ways. Within Confio (Ignite) and also when i run manually, i can see the plan handles are different.
Lynn Pettis
Lynn Pettis
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40462 Visits: 38567
Unfortunately, we can't see what you see. You have posted no code (the stored procedure, the CREATE TABLE statements for the table or tables it uses, sample data, expected results). Anything we give you right now will be simply shots in the dark.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
GilaMonster
GilaMonster
SSC Guru
SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)

Group: General Forum Members
Points: 89469 Visits: 45284
sqldba_newbie (3/29/2013)
Within Confio (Ignite) and also when i run manually, i can see the plan handles are different.


Can't help you with just that info. There's a lot of things that could be happening here, deferred compile being just one of them, but need a lot more info on what you're seeing and why the conclusion is multiple plans.

Maybe start by having a read through these, at worst they'll give you more things to look at.
http://sqlinthewild.co.za/index.php/2010/07/27/hit-and-miss/
http://sqlinthewild.co.za/index.php/2010/08/31/come-and-gone/
http://sqlinthewild.co.za/index.php/2010/11/18/recompiles/
http://sqlinthewild.co.za/index.php/2011/08/16/compiles-and-recompiles/

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


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