Question : Use of Sp_who to analyse problems

Hi Sybase Experts,

I'm trying to get to grips on how to fully utilise sp_who to find out what is going on in my server.
There is is the obviou stuff such as the spid and the status of the process. I assume runnning means running and sleep means waiting. But there are others and I want to know what they are and there significence.  Eg. When one process is blocking another and when a deadlock has occurred.  Also what does the blk column serve as? I assume that cmd is the current command being run by the spid.

Please advise. Thanks!


 
fid       spid       status       loginame       origname       hostname       blk       dbname       cmd         
0       2       sleeping                         0       master       NETWORK HANDLER         
0       3       sleeping                         0       master       DEADLOCK TUNE         
0       4       sleeping                         0       master       MIRROR HANDLER         
0       5       sleeping                         0       master       CHECKPOINT SLEEP         
0       6       sleeping                         0       master       HOUSEKEEPER         
0       11       running       fred       fred             0       test       SELECT       

Answer : Use of Sp_who to analyse problems

The documentation for sp_who in the Reference Guide goes into some detail for most of this.

You can find the various statuses (running, sleeping, lock sleep, etc) documented in the Reference Guide writeup for the system table sysprocesses.

Note that deadlocks aren't directly reported by sp_who, nor could a deadlock usually be inferred from its output.

When a process needs a lock that is incompatible with a lock held by a second process, the first process will show a status of "lock sleep", and the "blk" column (renamed blk-spid in more recent releases) will give the spid of the second process. We'd only see a cross-process spid reference here while a deadlock was actually alive - two processes each blocking each other - but Sybase detects and resolves this within half a second (by default).

For deadlocks, there will always be an error message returned to the client session of the process selected as the deadlock victim, and there will always be an error message written to the Sybase errorlog. Note! If you don't see that message in the Sybase errorlog, you did *not* have a deadlock, no matter what the application reports. (I've seen apps claim "deadlocks" when there wasn't a deadlock in the database.)

"Cmd" is the current low-level command being run by the spid, yes, but that won't usually be very interesting - "INSERT", "EXEC", "COND" (for conditional - an IF statement, for example). If you're running ASE 12.0 or above, you can get the exact text with dbcc sqltext. This needs SA privileges but there are tricks that can be used to allow non-SA people to run it as well.
Random Solutions  
 
programming4us programming4us