Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


High CPU usage (Because of bad execution plan)


High CPU usage (Because of bad execution plan)

Author
Message
Aspet Golestanian Namagerdi
Aspet Golestanian Namagerdi
SSC-Enthusiastic
SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)SSC-Enthusiastic (197 reputation)

Group: General Forum Members
Points: 197 Visits: 829
Hi everyone,

We have a server, which has SQL SERVER 2008 R2,periodically we face with high CPU usage(100%) on this server.We found out that the high CPU usage is related to a bad execution plan for a stored procedure.After recompiling the Stored Procedure,The CPU usage come back to normal.Is there any way to prevent cashing the bad execution plan ?


Thanks
Roland Alexander STL
Roland Alexander STL
Mr or Mrs. 500
Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)

Group: General Forum Members
Points: 520 Visits: 384
If the SP uses parameters in the WHERE or JOIN clauses, you might investigate the possibility that parameter sniffing caused a bad plan to be cached. There are many excellent articles on parameter sniffing available on SSC, just do a search of articles and blogs.

Roland Alexander
The Developing World


There are two means of refuge from the miseries of life: music and cats. ~ Albert Schweitzer
chandan_jha18
chandan_jha18
Mr or Mrs. 500
Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)

Group: General Forum Members
Points: 513 Visits: 2133
As stated above, it could be parameter sniffing. If you have identified what procedure runs that cause the sniffing capture that parameter in particular that causes this.

Now, don't put the recompile option for the procedure as a solution as that will be costly in the long run.
Use other methods like declaring a local variable and copying the procedure parameter to it.

Also, if you would like some experts to look into your code to make it more elegant, please post the DDL and execution plans.

Thanks
Chandan
Jason-299789
Jason-299789
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1134 Visits: 3229
If it is a paramater sniffing option and you are using SQL2008 you can use the Query Hint OPTION(RECOMPILE) on the offending SELECT statement, which should solve the issue and give you and indication if this is the case.

As the previous poster suggested try to avoid using WITH RECOMPILE on functions an SP's as that can cause more problems.

_________________________________________________________________________
SSC Guide to Posting and Best Practices
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