Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

How do I interpret sp_who2 results? Expand / Collapse
Author
Message
Posted Wednesday, October 24, 2007 12:31 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, November 05, 2013 9:05 AM
Points: 976, Visits: 59
I have been looking around at various articles and threads and in SQL Server 2005 Tutorial and have not come across the answers I need.

I know CPUTime is in milliseconds and DiskIO is about read and writes in bytes.

I have a couple SPIDs that are taking a long time and sometimes their status is SUSPENDED. Why would a SPID be marked as suspended? That SPID is not being blocked.

The CPUTime on this SPID is 6047344 and the DiskIO is 394101.

Another SPID has CPUTime of 6087203 and DiskIO of 683344 and has a status of RUNNABLE.

Both have been running for over an hour.

Does any of this indicate that the server can't handle the queries? Could the reason the status be set to suspended be because there are too many read and writes going on and the hard drive can't handle it?




Robert W. Marda
SQL Programmer
Ipreo
Post #414575
Posted Wednesday, October 24, 2007 1:26 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, August 10, 2010 5:07 AM
Points: 2,732, Visits: 23,078
SUSPENDED generally means the process is waiting on something that is not being done by MSSQL. For instance, if a long running process is waiting for the operating system to return something being read from disk and it take awhile, the process may be suspended while SQL waits for the operating system. Since the process is not under the control of the SQL server, it suspends the process until whatever it is waiting for is done.
I have seen this come up a few times while TempDB is expanding or a huge query is trying to pull a lot of data from a busy disk drive.
I also seem to remember this happening sometimes with linked servers waiting for the remote server to process something, but that part of my memory seems to be a bit fuzzy right now.
Post #414596
Posted Wednesday, October 24, 2007 1:30 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, November 05, 2013 9:05 AM
Points: 976, Visits: 59
Thanks for your reply. I know there are no linked servers being used so it won't be that. I suspect the hard drive and yes the two stored procedures being run by the two SPIDs pull a lot of data and then performs inserts and updates.



Robert W. Marda
SQL Programmer
Ipreo
Post #414599
Posted Wednesday, October 24, 2007 1:44 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, November 05, 2013 9:05 AM
Points: 976, Visits: 59
And does anyone know why sometimes I see more than one row for a particular SPID. For example I have one now that has 9 rows for one SPID. All I remember is that it has something to do with threads and/or paralelism, but I am pretty sure that server does not have 9 processors.



Robert W. Marda
SQL Programmer
Ipreo
Post #414608
Posted Wednesday, October 24, 2007 5:48 PM


Keeper of the Duck

Keeper of the Duck

Group: Moderators
Last Login: Thursday, April 03, 2014 10:06 PM
Points: 6,621, Visits: 1,851
Hi Robert,

have you tried querying sys.dm_os_waiting_tasks to see what the wait types are for the SPIDs?



K. Brian Kelley, CISA, MCSE, Security+, MVP - SQL Server
Regular Columnist (Security), SQLServerCentral.com
Author of Introduction to SQL Server: Basic Skills for Any SQL Server User
| Professional Development blog | Technical Blog | LinkedIn | Twitter
Post #414697
Posted Wednesday, October 24, 2007 6:16 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 24, 2010 1:57 PM
Points: 182, Visits: 65
along the same line....try using this script to tell your most expensive users for the past minute. It will review the processes and tell you who is using the most CPU over the past minute.


create procedure [dbo].[cspWhoCPU]
as
Select d.name as 'DatabaseName', spid, p.status, cmd,
p.loginame, nt_username, hostname, program_name,
cpu, physical_io, memusage, blocked
into ##FirstLook
from master.sys.sysprocesses p (nolock)
join master.sys.sysdatabases d (nolock)
on p.dbid = d.dbid
order by D.name, nt_username

waitfor delay '00:01:00'

Select d.name as 'DatabaseName', spid, p.status, cmd,
p.loginame, nt_username, hostname, program_name,
cpu, physical_io, memusage, blocked
into ##SecondLook
from master.sys.sysprocesses p (nolock)
join master.sys.sysdatabases d (nolock)
on p.dbid = d.dbid
order by D.name, nt_username


Select b.DatabaseName, b.spid, b.status, b.loginame,
b.nt_UserName, b.hostName, b.Program_name, b.spid,
B.cpu - isnull(A.cpu,0) as MinuteCPU,
b.cpu as TotCPU,
b.Physical_io - isnull(a.physical_io,0) as MinuteIO,
b.physical_IO as totIO,
b.memusage - isnull(a.memusage,0) as MinuteMem,
b.memusage as TotMem, b.blocked as BlkBy
from ##firstLook a
right outer join ##secondLook b
on a.spid = b.spid
and a.databasename = b.databaseName
and a.loginame = b.loginame
order by 9 desc,11 desc,13 desc

--select * from ##firstLook
--select * from ##secondLook

drop table ##firstLook
drop table ##SecondLook

Post #414707
Posted Wednesday, October 24, 2007 6:16 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 24, 2010 1:57 PM
Points: 182, Visits: 65
along the same line....try using this script to tell your most expensive users for the past minute. It will review the processes and tell you who is using the most CPU over the past minute.


create procedure [dbo].[cspWhoCPU]
as
Select d.name as 'DatabaseName', spid, p.status, cmd,
p.loginame, nt_username, hostname, program_name,
cpu, physical_io, memusage, blocked
into ##FirstLook
from master.sys.sysprocesses p (nolock)
join master.sys.sysdatabases d (nolock)
on p.dbid = d.dbid
order by D.name, nt_username

waitfor delay '00:01:00'

Select d.name as 'DatabaseName', spid, p.status, cmd,
p.loginame, nt_username, hostname, program_name,
cpu, physical_io, memusage, blocked
into ##SecondLook
from master.sys.sysprocesses p (nolock)
join master.sys.sysdatabases d (nolock)
on p.dbid = d.dbid
order by D.name, nt_username


Select b.DatabaseName, b.spid, b.status, b.loginame,
b.nt_UserName, b.hostName, b.Program_name, b.spid,
B.cpu - isnull(A.cpu,0) as MinuteCPU,
b.cpu as TotCPU,
b.Physical_io - isnull(a.physical_io,0) as MinuteIO,
b.physical_IO as totIO,
b.memusage - isnull(a.memusage,0) as MinuteMem,
b.memusage as TotMem, b.blocked as BlkBy
from ##firstLook a
right outer join ##secondLook b
on a.spid = b.spid
and a.databasename = b.databaseName
and a.loginame = b.loginame
order by 9 desc,11 desc,13 desc

--select * from ##firstLook
--select * from ##secondLook

drop table ##firstLook
drop table ##SecondLook

Post #414708
Posted Wednesday, October 24, 2007 6:16 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 24, 2010 1:57 PM
Points: 182, Visits: 65
along the same line....try using this script to tell your most expensive users for the past minute. It will review the processes and tell you who is using the most CPU over the past minute.


create procedure [dbo].[cspWhoCPU]
as
Select d.name as 'DatabaseName', spid, p.status, cmd,
p.loginame, nt_username, hostname, program_name,
cpu, physical_io, memusage, blocked
into ##FirstLook
from master.sys.sysprocesses p (nolock)
join master.sys.sysdatabases d (nolock)
on p.dbid = d.dbid
order by D.name, nt_username

waitfor delay '00:01:00'

Select d.name as 'DatabaseName', spid, p.status, cmd,
p.loginame, nt_username, hostname, program_name,
cpu, physical_io, memusage, blocked
into ##SecondLook
from master.sys.sysprocesses p (nolock)
join master.sys.sysdatabases d (nolock)
on p.dbid = d.dbid
order by D.name, nt_username


Select b.DatabaseName, b.spid, b.status, b.loginame,
b.nt_UserName, b.hostName, b.Program_name, b.spid,
B.cpu - isnull(A.cpu,0) as MinuteCPU,
b.cpu as TotCPU,
b.Physical_io - isnull(a.physical_io,0) as MinuteIO,
b.physical_IO as totIO,
b.memusage - isnull(a.memusage,0) as MinuteMem,
b.memusage as TotMem, b.blocked as BlkBy
from ##firstLook a
right outer join ##secondLook b
on a.spid = b.spid
and a.databasename = b.databaseName
and a.loginame = b.loginame
order by 9 desc,11 desc,13 desc

--select * from ##firstLook
--select * from ##secondLook

drop table ##firstLook
drop table ##SecondLook

Post #414709
Posted Thursday, October 25, 2007 5:15 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, August 10, 2010 5:07 AM
Points: 2,732, Visits: 23,078
That was some nice stuff.

Your other question - the same spid multiple times. This is caused by parallel processing. Look up the MAX DOP or Max Degrees of Parallelism in books online.

Also, if your query is waiting a long time in SUSPENDED and you think it is the hard drive, use perfmon to look at the drive usage before and during the query running to make sure. If that is the case, you are likely to have a problem with your query and need to resolve it.
Post #414889
Posted Friday, October 26, 2007 5:58 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, April 17, 2014 5:22 AM
Points: 881, Visits: 1,352
The Performance_Dashboard reports are very helpful. They do a good job of drilling down.

http://www.microsoft.com/downloads/details.aspx?FamilyId=1d3a4a0d-7e0c-4730-8204-e419218c1efc&displaylang=en



Post #415324
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse