SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


CPU 100%, current queries show "CREATE PROCEDURE ... "


CPU 100%, current queries show "CREATE PROCEDURE ... "

Author
Message
Boris Pazin
Boris Pazin
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 216
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!
anthony.green
anthony.green
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10460 Visits: 6378
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
When a question, really isn't a question - Jeff Smith
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


Dennis Post
Dennis Post
SSC-Addicted
SSC-Addicted (407 reputation)SSC-Addicted (407 reputation)SSC-Addicted (407 reputation)SSC-Addicted (407 reputation)SSC-Addicted (407 reputation)SSC-Addicted (407 reputation)SSC-Addicted (407 reputation)SSC-Addicted (407 reputation)

Group: General Forum Members
Points: 407 Visits: 547
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.

"Million-to-one chances crop up nine times out of ten." ― Terry Pratchett, Mort
Boris Pazin
Boris Pazin
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 216
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. Unsure
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91679 Visits: 45285
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, MVP, M.Sc (Comp Sci)
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


Boris Pazin
Boris Pazin
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 216
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 Sick


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?
Boris Pazin
Boris Pazin
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 216
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.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91679 Visits: 45285
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, MVP, M.Sc (Comp Sci)
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


Boris Pazin
Boris Pazin
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 216
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 :-)
Boris Pazin
Boris Pazin
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 216
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. Wow
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