What's blocking

  • Hi,

    I have script that I use to monitor blcked/blocking SPIDS. I am trying to tie this information to actual blocked resources.

    We have extensive blocking going on the database because of the application that queues the requests to the database and apprently create blockings. We have over 60000 tables in the database which makes it practically impossible to use lot of GUI tools.

    Blocked processes moved pretty fast too. By the time I get SPID info and try to see locks, SPID is gone.

    Does anyone have any script that ties the info for blocking/blocked SPIDS to the lock it is waiting on?

    or any suggestion on how to get some useful info from monitoring processes using sp-who2 or other scripts to monitor blocking?

    Thanks,

  • Did you try the Profiler? Remember to add filter if you decide to use it.

  • You can try use the sp_blocker_pss80 :

    http://support.microsoft.com/kb/271509

  • Try this script:

    SELECT p.spid

    ,convert(char(12), d.name) db_name

    , program_name

    , convert(char(12), l.name) login_name

    , convert(char(12), hostname) hostname

    , cmd

    , p.status

    , p.blocked

    , login_time

    , last_batch

    , p.spid

    FROM master..sysprocesses p

    JOIN master..sysdatabases d ON p.dbid = d.dbid

    JOIN master..syslogins l ON p.sid = l.sid

    WHERE p.blocked = 0

    AND EXISTS ( SELECT 1

    FROM master..sysprocesses p2

    WHERE p2.blocked = p.spid )

  • I think that you should have a look at the 'Blocked Process Report' events.

    You can define that you would like to generate a 'Blocked Process Report' if a process is blocked for more than a number of seconds.

    The threshold is set with a sp_configure option.

    http://msdn2.microsoft.com/en-us/library/ms181150.aspx

    The 'Blocked Process Report' contains information about the blocked and blocking process.

    http://msdn2.microsoft.com/en-us/library/ms191168.aspx

    Then you could capture these events using SQL Trace or Event Notifications. If you're using Event Notifications you could have the events inserted into a table.

    http://msdn2.microsoft.com/en-us/library/ms190427.aspx

    Ola Hallengren

    http://ola.hallengren.com

  • Does anyone have a query to extract the contents of from the blocked process report? I have thousands of blocked process report rows; I need to analyze which queries are most often blocked/blocking. Interestingly, most of the blocking occurs during the full backups.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply