October 21, 2010 at 11:51 am
I have a proc that runs very slowly on my prod server, it take over 3 minutes to return results.
If I make a backup of the DB and move it to my stage server the same exact procs run in two seconds.
I'm assuming this must mean that the slowness is caused by something in my prod environment?
If so, what can I look for?
Is it safe to say it's nothing in the DB, since it runs fine on stage?
btw- the prod environment is not very busy...cpu, disk io, etc all very low levels..
October 21, 2010 at 11:56 am
Compare both execution plans to find the difference.
It's likely a parameter sniffing issue (plenty of articles in google about that)
October 21, 2010 at 12:07 pm
the execution plans appear to be the same...
October 21, 2010 at 12:12 pm
make sure you are comparing the actual execution plans, and not the estimated plans....
the estimated woudl probably be teh same on both, but the performance issue is in the actual...where something goes wrong.....
Lowell
October 21, 2010 at 12:25 pm
okay so I followed your advise ...ran the execution plan on both prod and stage boxes..
On my prod box (query 4) I have a clustered index scan..cost of 81 percent
I don't have that on my stage box..
October 22, 2010 at 1:36 am
It sounds like a parameter sniffing issue. A quick fix would be to recompile the procedure on prod and see if the plan changes.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 22, 2010 at 1:48 am
Is the memory configuration different on prod and dev?
If so, this could perhaps be caused by this bug http://support.microsoft.com/kb/2413549
October 22, 2010 at 7:45 am
I re-complied but slowness still exists..
We are gonna try bouncing the server this weekend.
October 22, 2010 at 7:50 am
You may drop and recreate the proc or use the "with recompile" option.
Online Trainer For SQL DBA and Developer @RedBushTechnologies with 18 yrs exp.
October 22, 2010 at 7:51 am
There are a few ways. You can modify the proc to include WITH RECOMPILE as a hint, I don't suggest that though. Another way is to get the plan handle from sys.dm_exec_query_stats (or wherever plan handles are stored, there are lots of places to get them) and then run DBCC freeproccache (<guid>). Easiest, you can execute the procedure and say WITH RECOMPILE.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 22, 2010 at 7:57 am
Is it returning same data on both machines? I mean are u using same parameters on both machines?
Online Trainer For SQL DBA and Developer @RedBushTechnologies with 18 yrs exp.
October 22, 2010 at 8:01 am
Grant
I believe DBCC freeproccache (<guid>). will work on 2008 only....
Online Trainer For SQL DBA and Developer @RedBushTechnologies with 18 yrs exp.
October 22, 2010 at 8:24 am
SureshS_DBA (10/22/2010)
GrantI believe DBCC freeproccache (<guid>). will work on 2008 only....
Confirmed, doesn't work on sql 2005 standard SP 2
October 22, 2010 at 8:32 am
Oops. I spend most of my time in 2008 these days. I tend to bleed that stuff back down the chain sometimes.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 15 posts - 1 through 15 (of 60 total)
You must be logged in to reply to this topic. Login to reply