![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a problem with a production SQL box. The problem is that once or twice a day the box is getting its processor allocated for 100% for 10+ seconds. How can I find out what command or something causes that? Thanks |
#3
| |||
| |||
|
|
I have a problem with a production SQL box. The problem is that once or twice a day the box is getting its processor allocated for 100% for 10+ seconds. How can I find out what command or something causes that? Thanks |
#4
| |||
| |||
|
|
If you take quick snapshots of sysprocesses when the CPU usage is high, and find the incremental cpu usage between the consecutive snapshots for each spid for the same session, you can find the sessions that are the largest CPU consumers at the time, and that can usually help you determine what SQL statements are contributing to the the high CPU usage. |
#5
| |||
| |||
|
|
beta_lockinfo is available on my website: http://www.sommarskog.se/sqlutil/beta_lockinfo.html |
|
Linchi Shea (LinchiShea (AT) discussions (DOT) microsoft.com) writes: If you take quick snapshots of sysprocesses when the CPU usage is high, and find the incremental cpu usage between the consecutive snapshots for each spid for the same session, you can find the sessions that are the largest CPU consumers at the time, and that can usually help you determine what SQL statements are contributing to the the high CPU usage. And if you instead use beta_lockinfo, which includes a CPU column, you can also see what that process is up to. beta_lockinfo is available on my website: http://www.sommarskog.se/sqlutil/beta_lockinfo.html -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx |
#6
| |||
| |||
|
|
all these joins on the DMVs. But often (1) you don't know when a performance problem may appear and (2) when it occurs, it may disappear before you get there, so you may have to collect data continuously or at a fairly high frequency (say once every few seconds). |
|
One solution is to collect perf data lightly (in terms of its perf impact) but regularly, and shift heavy processing to the reporting/query time. And if you store the data somewher else, you can afford to run fancy joins to look for the info you want. |
#7
| |||
| |||
|
|
Linchi Shea (LinchiShea (AT) discussions (DOT) microsoft.com) writes: If you take quick snapshots of sysprocesses when the CPU usage is high, and find the incremental cpu usage between the consecutive snapshots for each spid for the same session, you can find the sessions that are the largest CPU consumers at the time, and that can usually help you determine what SQL statements are contributing to the the high CPU usage. And if you instead use beta_lockinfo, which includes a CPU column, you can also see what that process is up to. beta_lockinfo is available on my website: http://www.sommarskog.se/sqlutil/beta_lockinfo.html -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx |
#8
| |||
| |||
|
|
In my experience, performance problems that are shorter than your tolerance for querying the DMVs (depending on how hard you are querying them), are not really problems. |
|
all these joins on the DMVs. But often (1) you don't know when a performance problem may appear and (2) when it occurs, it may disappear before you get there, so you may have to collect data continuously or at a fairly high frequency (say once every few seconds). In my experience, performance problems that are shorter than your tolerance for querying the DMVs (depending on how hard you are querying them), are not really problems. The Resource Governor works in the same way... It only checks for long-running queries so often; anything shorter is ignored. One solution is to collect perf data lightly (in terms of its perf impact) but regularly, and shift heavy processing to the reporting/query time. And if you store the data somewher else, you can afford to run fancy joins to look for the info you want. I do agree with this. The key is to collect the bare minimum on a routine schedule. An extension would be to add code that dynamically determines that a problem is creeping up and at that point take the more detailed info for a few cycles. |
#9
| |||
| |||
|
|
The values in that column is cumulative. And cumulative values usually don't mean anything in terms of their magnitude unless you have a feel for teh time span in which the value is cumulated. You need to take a difference to find how many CPU milliseconds are consumed by that spid in that time period. In addition, when you do take that diff or delta, make sure it is still the same session because spid can be reused and doing a cpu diff for the same spid but different sessions is meaningless. Linchi "Mark Goldin" wrote: How do I properly read a column "cpu"? I see some very big numbers there. Thanks "Erland Sommarskog" <esquel (AT) sommarskog (DOT) se> wrote in message news:Xns9C3AF35BB3B90Yazorman (AT) 127 (DOT) 0.0.1... Linchi Shea (LinchiShea (AT) discussions (DOT) microsoft.com) writes: If you take quick snapshots of sysprocesses when the CPU usage is high, and find the incremental cpu usage between the consecutive snapshots for each spid for the same session, you can find the sessions that are the largest CPU consumers at the time, and that can usually help you determine what SQL statements are contributing to the the high CPU usage. And if you instead use beta_lockinfo, which includes a CPU column, you can also see what that process is up to. beta_lockinfo is available on my website: http://www.sommarskog.se/sqlutil/beta_lockinfo.html -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx |
#10
| |||
| |||
|
|
I understand about the same spid but I am not sure about: how many CPU milliseconds are consumed by that spid in that time period What is 'that time period'? Thanks "Linchi Shea" <LinchiShea (AT) discussions (DOT) microsoft.com> wrote in message news:BB36606B-4C07-48E3-AF26-44FD28C16A48 (AT) microsoft (DOT) com... The values in that column is cumulative. And cumulative values usually don't mean anything in terms of their magnitude unless you have a feel for teh time span in which the value is cumulated. You need to take a difference to find how many CPU milliseconds are consumed by that spid in that time period. In addition, when you do take that diff or delta, make sure it is still the same session because spid can be reused and doing a cpu diff for the same spid but different sessions is meaningless. Linchi "Mark Goldin" wrote: How do I properly read a column "cpu"? I see some very big numbers there. Thanks "Erland Sommarskog" <esquel (AT) sommarskog (DOT) se> wrote in message news:Xns9C3AF35BB3B90Yazorman (AT) 127 (DOT) 0.0.1... Linchi Shea (LinchiShea (AT) discussions (DOT) microsoft.com) writes: If you take quick snapshots of sysprocesses when the CPU usage is high, and find the incremental cpu usage between the consecutive snapshots for each spid for the same session, you can find the sessions that are the largest CPU consumers at the time, and that can usually help you determine what SQL statements are contributing to the the high CPU usage. And if you instead use beta_lockinfo, which includes a CPU column, you can also see what that process is up to. beta_lockinfo is available on my website: http://www.sommarskog.se/sqlutil/beta_lockinfo.html -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx |
![]() |
| Thread Tools | |
| Display Modes | |
| |