Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How do I interpret sp_who2 results?


How do I interpret sp_who2 results?

Author
Message
Robert W Marda
Robert W Marda
SSC Eights!
SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)

Group: General Forum Members
Points: 986 Visits: 82
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

Michael Earl-395764
Michael Earl-395764
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2711 Visits: 23078
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.
Robert W Marda
Robert W Marda
SSC Eights!
SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)

Group: General Forum Members
Points: 986 Visits: 82
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

Robert W Marda
Robert W Marda
SSC Eights!
SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)SSC Eights! (986 reputation)

Group: General Forum Members
Points: 986 Visits: 82
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

K. Brian Kelley
K. Brian Kelley
Keeper of the Duck
Keeper of the Duck (6.8K reputation)

Group: Moderators
Points: 6826 Visits: 1917
Hi Robert,

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

K. Brian Kelley
@‌kbriankelley
Eric Peterson
Eric Peterson
SSC-Enthusiastic
SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)

Group: General Forum Members
Points: 184 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
Eric Peterson
Eric Peterson
SSC-Enthusiastic
SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)

Group: General Forum Members
Points: 184 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
Eric Peterson
Eric Peterson
SSC-Enthusiastic
SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)

Group: General Forum Members
Points: 184 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
Michael Earl-395764
Michael Earl-395764
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2711 Visits: 23078
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.
Steve-3_5_7_9
Steve-3_5_7_9
SSC Eights!
SSC Eights! (982 reputation)SSC Eights! (982 reputation)SSC Eights! (982 reputation)SSC Eights! (982 reputation)SSC Eights! (982 reputation)SSC Eights! (982 reputation)SSC Eights! (982 reputation)SSC Eights! (982 reputation)

Group: General Forum Members
Points: 982 Visits: 1584
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



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