|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, January 21, 2013 6:34 AM
Points: 31,
Visits: 87
|
|
I have a issue i am struggling with. I have a sp that returns 1700 records in about 1 minute but when i run the same exact sql in an adhoc query it takes on 5 seconds?
I declare a table variable for a summary table, load the table then join the results with 4 other tables. It doesn't seem to be anything out the ordinary but the sp will timeout when running via the applcation.
I seem to be just banging my head against the wall at this point! Any assistance is appreciated.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 4:50 AM
Points: 13,371,
Visits: 25,143
|
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: 2 days ago @ 1:56 PM
Points: 6,997,
Visits: 13,941
|
|
It seems rather extreme - but could it be parameter sniffing?
Ken Henderson (you will be missed) described it rather well here:
http://blogs.msdn.com/khen1234/archive/2005/06/02/424228.aspx
---------------------------------------------------------------------------------- Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, April 23, 2013 12:18 PM
Points: 1,103,
Visits: 1,781
|
|
I wonder if the procedure hasn't recompiled since your last change and is using an old execution plan? Might want to try doing a freeproccache for s&g's ...
Regardless, have you looked at the execution plan with the procedure and compared it to the execution plan when running it via TSQL?
--
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 4:50 AM
Points: 13,371,
Visits: 25,143
|
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, January 21, 2013 6:34 AM
Points: 31,
Visits: 87
|
|
Thanks for all your responses.
This issue appears to be wide spread and happening on several stored procedures. Now even my adhoc queries are taking extremely long time to return results.
Just a little background, we just moved several dB's to production from our test. Both environments are sql server 2005. We did not have any issues in the test environment.
I am far from a DBA, but I have never encountered these performance issues from copying stored procedures from one server to anohter.
Has anyone heard of any issues similar to this?
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, April 23, 2013 12:18 PM
Points: 1,103,
Visits: 1,781
|
|
First and foremost, you need to look at your execution plans ... your problem could be one of MANY things at this point.
Run your query in query analyzer/management studio, with execution plan turned on. You'll get a new output tab showing the execution plan. Look for the highest percentages used from step to step to start determining where the most resources are used.
--
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 10:27 AM
Points: 37,648,
Visits: 29,900
|
|
Check the sys.dm_exec_requests DMV. What are the long running queries waiting on?
Have you rebuilt indexes recently?
Does recompiling the procedure make any difference? (EXEC sp_recompile 'StoredProcName')
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
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Sunday, September 16, 2012 3:26 AM
Points: 1,038,
Visits: 443
|
|
Silly question, but how much more data do you have in production compared to your test environment? Is your test data obviously fake test data such as lots of similar names, etc?
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 8:50 AM
Points: 3,572,
Visits: 5,106
|
|
>>Has anyone heard of any issues similar to this?
Yeah, we all have! ) The problem is that the potential causes are quite numerous. Even without knowing your code or data structures or data distributions I could probably rattle off 15 or 20 different possibles. In situations like this there is no substitute for experience - it's gonna be a painful process going back and forth via forum posts. Don't suppose you have a DBA at work you can hit up? 10-20 minutes of their time (if that) online with you data should be all it takes to isolate the cause.
Best,
Kevin G. Boles SQL Server Consultant SQL MVP 2007-2012 TheSQLGuru at GMail
|
|
|
|