Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

multiple execution plans - not sure why? Expand / Collapse
Author
Message
Posted Friday, March 29, 2013 10:49 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:43 PM
Points: 1,274, Visits: 2,936

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?
Post #1437017
Posted Friday, March 29, 2013 12:31 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Today @ 5:16 PM
Points: 568, Visits: 69,860
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?
Post #1437052
Posted Friday, March 29, 2013 1:19 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:46 PM
Points: 42,462, Visits: 35,525
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 2008, MVP
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

Post #1437068
Posted Friday, March 29, 2013 1:35 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:43 PM
Points: 1,274, Visits: 2,936
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.
Post #1437073
Posted Friday, March 29, 2013 1:35 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:43 PM
Points: 1,274, Visits: 2,936
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.
Post #1437074
Posted Friday, March 29, 2013 1:56 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 5:21 PM
Points: 23,031, Visits: 31,553
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.



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)
Post #1437084
Posted Friday, March 29, 2013 5:02 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:46 PM
Points: 42,462, Visits: 35,525
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 2008, MVP
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

Post #1437142
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse