Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Administering
»
CPU 100%, current queries show "CREATE...
17 posts, Page 1 of 2
1
2
»»
CPU 100%, current queries show "CREATE PROCEDURE ... "
Rate Topic
Display Mode
Topic Options
Author
Message
Boris Pazin
Boris Pazin
Posted Thursday, September 27, 2012 6:16 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:18 PM
Points: 22,
Visits: 124
Hi,
I have a SQL Server 2005, which works fine and on some time it starts to use 100% of CPU. Then website is slow, get timeout messages etc.
I used this query to find current queries:
SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
When I run query above, it shows me about 40 records, and most of them are code for creating stored procedures. Same like when you go in Management Studio "Script stored procedure As", and then select "CREATE to".
So, it looks like these 3 stored procedures are constantly re-created.
After a while, I restarted the server and now it works fine. But, it repeats this behavior every day.
Anyone have an idea what could cause this?
Thanks!
Post #1365183
anthony.green
anthony.green
Posted Thursday, September 27, 2012 6:24 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
Restarting SQL is not a good idea as it flushes it's cache and when it restarts has to build the cache again which makes performance worse (usually)
A good place to start would be here
http://www.simple-talk.com/books/sql-books/troubleshooting-sql-server-a-guide-for-the-accidental-dba/
- Chapter 3 High CPU Utilisation.
Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1
&
Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger
Post #1365186
Dennis Post
Dennis Post
Posted Thursday, September 27, 2012 6:57 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 1:04 AM
Points: 109,
Visits: 282
If you have access to SSMS 2008 you can right click on the instance name and select Activity Monitor.
This will give you a good place to start troubleshooting.
For better, quicker answers on T-SQL questions, read Jeff Moden's suggestions.
http://www.sqlservercentral.com/articles/Best+Practices/61537/
"Million-to-one chances crop up nine times out of ten." ― Terry Pratchett, Mort
Post #1365209
Boris Pazin
Boris Pazin
Posted Thursday, September 27, 2012 7:28 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:18 PM
Points: 22,
Visits: 124
anthony.green (9/27/2012)
Restarting SQL is not a good idea as it flushes it's cache and when it restarts has to build the cache again which makes performance worse (usually)
It is production server. Users can't login, can't browse website and things become urgent.
Post #1365246
GilaMonster
GilaMonster
Posted Thursday, September 27, 2012 7:37 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 4:38 AM
Points: 37,677,
Visits: 29,931
The stored procedures are not being recreated. They're being executed.
Find the worst performing code, tune it. Repeat until performance acceptable.
http://www.simple-talk.com/sql/performance/finding-the-causes-of-poor-performance-in-sql-server,-part-1/
http://www.simple-talk.com/sql/performance/finding-the-causes-of-poor-performance-in-sql-server,-part-2/
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 #1365262
Boris Pazin
Boris Pazin
Posted Thursday, September 27, 2012 7:39 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:18 PM
Points: 22,
Visits: 124
D.Post (9/27/2012)
If you have access to SSMS 2008 you can right click on the instance name and select Activity Monitor.
This will give you a good place to start troubleshooting.
I checked current activity, and found that there is a lot of queries for creating of procedures.
The problem is, that queries should not be executed at all. That stored procedures already exist on server for a long time. No need to run CREATE PROCEDURE query for them at all.
I have no idea why these queries are executed on the first place
So, in certain time, SQL Server executes a lot of same queries for creating of same procedures (procedures already exist on server) and CPU goes 100%.
The queries which are executed in that time are useless, I don't need them at all, and don't know from where they are coming.
How that could be possible?
Post #1365265
Boris Pazin
Boris Pazin
Posted Thursday, September 27, 2012 7:42 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:18 PM
Points: 22,
Visits: 124
GilaMonster (9/27/2012)
The stored procedures are not being recreated. They're being executed.
Find the worst performing code, tune it. Repeat until performance acceptable.
http://www.simple-talk.com/sql/performance/finding-the-causes-of-poor-performance-in-sql-server,-part-1/
http://www.simple-talk.com/sql/performance/finding-the-causes-of-poor-performance-in-sql-server,-part-2/
Gila,
thanks for replay.
Website is using procedures for showing data, that part works OK.
The problem is that current queries are scripts for creating procedures, not for executing them.
Post #1365267
GilaMonster
GilaMonster
Posted Thursday, September 27, 2012 7:44 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 4:38 AM
Points: 37,677,
Visits: 29,931
Boris Pazin (9/27/2012)
The problem is that current queries are scripts for creating procedures, not for executing them.
The procedures are not being created. They are being executed.
When you execute a procedure, the sql_text DMV shows the create so that you can use the statement offsets to get the exact statement executing.
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 #1365269
Boris Pazin
Boris Pazin
Posted Thursday, September 27, 2012 7:53 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:18 PM
Points: 22,
Visits: 124
GilaMonster (9/27/2012)
Boris Pazin (9/27/2012)
The problem is that current queries are scripts for creating procedures, not for executing them.
The procedures are not being created. They are being executed.
When you execute a procedure, the sql_text DMV shows the create so that you can use the statement offsets to get the exact statement executing.
Wow, that is interesting!
GilaMonster, you say, if I call query above to see current queries, it will show CREATE PROCEDURE text???
Must check this immediately
Post #1365276
Boris Pazin
Boris Pazin
Posted Thursday, September 27, 2012 8:16 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:18 PM
Points: 22,
Visits: 124
GilaMonster (9/27/2012)
Boris Pazin (9/27/2012)
The problem is that current queries are scripts for creating procedures, not for executing them.
The procedures are not being created. They are being executed.
When you execute a procedure, the sql_text DMV shows the create so that you can use the statement offsets to get the exact statement executing.
Thanks!!!!
Things finally make sense.
Post #1365294
« Prev Topic
|
Next Topic »
17 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.