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 2008
»
SQL Server 2008 - General
»
SQL Query causing CPU Spikes on SQL Server...
29 posts, Page 1 of 3
1
2
3
»
»»
SQL Query causing CPU Spikes on SQL Server 2008 r2
Rate Topic
Display Mode
Topic Options
Author
Message
APA0876
APA0876
Posted Thursday, January 10, 2013 2:17 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 1:46 PM
Points: 112,
Visits: 255
Hi,
I have a curious case here: there is a SQL Query that is causing 90% of CPU on one of the SQL servers also it run in 14 seconds, on other server with similar specs the query executes in less than a second and no cpu spikes also the server configurations are the same:
What can be happening here?
select distinct
spid = cast(p.spid as int),
program = p.program_name,
host = p.hostname,
login = p.loginame,
databasename = replace(db_name(ISNULL(convert(int,l.rsc_dbid),-1)),char(39),char(39)+char(39)),
object = ISNULL(l.rsc_objid,-1),
request_mode = substring (v.name, 1, 8),
blockedwait = b.waittime,
inputbuffer = case when isnull(p.net_address, '') = '' then null else (select case when dmv.objectid is null then left(max(text),4000) else null end from sys.dm_exec_sql_text(p.sql_handle) dmv group by dmv.objectid) end,
starttime = dateadd(ss,cast(b.waittime as float)/1000 * -1,getutcdate())
from
master..sysprocesses p (nolock)
left join master..sysprocesses b (nolock)
on p.spid = b.blocked
left outer join master..syslockinfo l (nolock)
on b.spid = l.req_spid
and l.req_status in (2,3)
left join master.dbo.spt_values v
on convert(int,l.[req_mode]) + 1 = v.number
where
p.blocked = 0
and p.program_name not like 'SQLAgent%'
and p.program_name not in ('SQL PerfMon')
and b.blocked <> 0
and b.waittime > 166000
and v.type = 'L'
Thanks for your help
Post #1405643
Vedran Kesegic
Vedran Kesegic
Posted Thursday, January 10, 2013 7:05 PM
Old Hand
Group: General Forum Members
Last Login: Thursday, May 16, 2013 8:08 AM
Points: 342,
Visits: 1,072
Check if actual execution plans are different. Are those virtual machines?
_____________________________________________________
XDetails Addin
- for SQL Developers and DBA
blog.sqlxdetails.com
- Transaction log myths - debunked!
Post #1405722
SQLRNNR
SQLRNNR
Posted Thursday, January 10, 2013 8:12 PM
SSCoach
Group: General Forum Members
Last Login: Yesterday @ 1:07 PM
Points: 18,733,
Visits: 12,332
Please provide the actual execution plan for both servers for the query.
Jason
AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1405734
APA0876
APA0876
Posted Thursday, January 10, 2013 9:06 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 1:46 PM
Points: 112,
Visits: 255
How can I send the execution plan on an xml format?
Thanks
Post #1405746
SQLRNNR
SQLRNNR
Posted Thursday, January 10, 2013 9:13 PM
SSCoach
Group: General Forum Members
Last Login: Yesterday @ 1:07 PM
Points: 18,733,
Visits: 12,332
See the first link in my signature. The instructions for posting the exec plan are there.
Jason
AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1405748
Bhuvnesh
Bhuvnesh
Posted Thursday, January 10, 2013 11:54 PM
SSCrazy
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 8:41 AM
Points: 2,562,
Visits: 3,451
APA0876 (1/10/2013)
there is a SQL Query that is causing 90% of CPU on one of the SQL servers also it run in 14 seconds, on other server with similar specs the query executes in less than a second and no cpu spikes also the server configurations are the same:
did you run the query at the same time?
are both(or other servers ) returning same records for this query ?
do both servers have same load (like job or background prcosses)
do they have same equal no of connections (at the time of query) ?
-------Bhuvnesh----------
While 1 = 1 (Learning SQL....)
Click to get fast response of your post
Post #1405782
APA0876
APA0876
Posted Friday, January 11, 2013 8:10 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 1:46 PM
Points: 112,
Visits: 255
Bhuvnesh (1/10/2013)
APA0876 (1/10/2013)
there is a SQL Query that is causing 90% of CPU on one of the SQL servers also it run in 14 seconds, on other server with similar specs the query executes in less than a second and no cpu spikes also the server configurations are the same:
did you run the query at the same time?
are both(or other servers ) returning same records for this query ?
do both servers have same load (like job or background prcosses)
do they have same equal no of connections (at the time of query) ?
Yes I run the query at the same time
Yes 0 records
different Load the server with the spikes is 20 % avg CPU and the other 5% Avg CPU
On the server having the CPU spike there are 1700 connections and the other 10 connections.
But what should I do, this query is exected every 6 minutes because is part of a diagnostic Tool.
Thanks
Ailyn
Post #1406055
anthony.green
anthony.green
Posted Friday, January 11, 2013 8:18 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
I would completly re-write it all, for one all the tables used are depreciated and are in the product for SQL 2000 compatability only, you really should be using the DMV's.
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 #1406063
SQLRNNR
SQLRNNR
Posted Friday, January 11, 2013 8:18 AM
SSCoach
Group: General Forum Members
Last Login: Yesterday @ 1:07 PM
Points: 18,733,
Visits: 12,332
APA0876 (1/11/2013)
Bhuvnesh (1/10/2013)
APA0876 (1/10/2013)
there is a SQL Query that is causing 90% of CPU on one of the SQL servers also it run in 14 seconds, on other server with similar specs the query executes in less than a second and no cpu spikes also the server configurations are the same:
did you run the query at the same time?
are both(or other servers ) returning same records for this query ?
do both servers have same load (like job or background prcosses)
do they have same equal no of connections (at the time of query) ?
Yes I run the query at the same time
Yes 0 records
different Load the server with the spikes is 20 % avg CPU and the other 5% Avg CPU
On the server having the CPU spike there are 1700 connections and the other 10 connections.
But what should I do,
this query is exected every 6 minutes because is part of a diagnostic Tool.
Thanks
Ailyn
Post the execution plans so we can better see what is happening and provide better answers.
Jason
AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1406064
APA0876
APA0876
Posted Friday, January 11, 2013 8:40 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 1:46 PM
Points: 112,
Visits: 255
APA0876 (1/10/2013)
How can I send the execution plan on an xml format?
Thanks
I posted two SQLPlans one for the server with the spike and the other sql for server that is OK
Post Attachments
ServerWSpike.sqlplan
(
10 views,
75.46 KB
)
ServerOK.sqlplan
(
2 views,
72.49 KB
)
Post #1406090
« Prev Topic
|
Next Topic »
29 posts, Page 1 of 3
1
2
3
»
»»
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.