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 123»»»

Using the Blocked Process Report in SQL Server 2005/2008 Expand / Collapse
Author
Message
Posted Thursday, October 30, 2008 12:12 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Wednesday, February 19, 2014 11:15 AM
Points: 1,708, Visits: 1,790
Comments posted to this topic are about the item Using the Blocked Process Report in SQL Server 2005/2008

Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
My Blog | Twitter | MVP Profile
Training | Consulting | Become a SQLskills Insider
Troubleshooting SQL Server: A Guide for Accidental DBAs
Post #594104
Posted Thursday, October 30, 2008 7:27 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, May 01, 2009 12:18 PM
Points: 12, Visits: 12
This looks like a good way to track blocking (much more proactive than the monitor window...) but what kind of performance hit will the server take? I have some blocking issues in my production server that I need to resolve but I don't want to add to the problem by running an additional process. I may be answering my own question but I guess any blocking would put more strain on the server anyway so resolving that quickly would be more essential.

Should this trace run all the time?

What about cleaning up the trace file?

Thanks - great article!
Post #594279
Posted Thursday, October 30, 2008 7:37 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Wednesday, February 19, 2014 11:15 AM
Points: 1,708, Visits: 1,790
The blocked process monitor is actually piggy backing on the deadlock monitor background thread, which is always running, so impact is very minimal. This is covered in the BOL topic for the option:

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

It also states that the reporting is done on a best effort basis, without guarantees for real-time or close to real time.

I don't recommend that you run this, just to have it running. I only use this when I have a need to look for specific blocking, or I suspect blocking to be the cause of a performance degradation.


Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
My Blog | Twitter | MVP Profile
Training | Consulting | Become a SQLskills Insider
Troubleshooting SQL Server: A Guide for Accidental DBAs
Post #594292
Posted Thursday, October 30, 2008 9:03 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, March 20, 2014 7:32 AM
Points: 5,191, Visits: 1,368
Very useful one ...


Post #594419
Posted Friday, December 05, 2008 8:02 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 7:22 AM
Points: 69, Visits: 770
I don't know whether to always believe the blocked process report. At times I see lots of purported blocking like this, where one select statement is supposedly blocking another. As you can see, we're using the default isolation level, read committed. ( I altered the hostname and loginname fields, and had to replace the ">" with "]" to get the xml to appear in this post for some reason).

If nothing else, the blocked process report does not tell me how/why one query is blocking another.

<blocked-process-report monitorLoop="1649082"]
<blocked-process]
<process id="process38132e8" taskpriority="0" logused="0" waitresource="PAGE: 17:4:94458" waittime="87078" ownerId="13262486200" transactionname="SELECT" lasttranstarted="2008-12-03T13:23:16.110" XDES="0x4e10c8558" lockMode="S" schedulerid="2" kpid="5372" status="suspended" spid="98" sbid="0" ecid="0" priority="0" transcount="0" lastbatchstarted="2008-12-03T13:23:16.110" lastbatchcompleted="2008-12-03T13:23:16.110" clientapp=".Net SqlClient Data Provider" hostname="xxx" hostpid="7216" loginname="xxx" isolationlevel="read committed (2)" xactid="13262486200" currentdb="17" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056"]
<executionStack]
<frame line="1" sqlhandle="0x020000003c2fd4171752b341f4fb2e78c4fd25a39d3268cb"/]
<frame line="1" sqlhandle="0x02000000272ffe37c5c986299be2ada0f87a7d86ca14ff81"/]
</executionStack]
<inputbuf]
select count(*) from employees where client_id=11343 and isadmin=1 </inputbuf]
</process]
</blocked-process]
<blocking-process]
<process status="suspended" waitresource="PAGE: 17:4:94458" waittime="100500" spid="161" sbid="0" ecid="0" priority="0" transcount="0" lastbatchstarted="2008-12-03T13:23:02.657" lastbatchcompleted="2008-12-03T13:23:02.657" clientapp=".Net SqlClient Data Provider" hostname="xxx" hostpid="7216" loginname="xxx" isolationlevel="read committed (2)" xactid="13262406360" currentdb="17" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056"]
<executionStack]
<frame line="1" sqlhandle="0x0200000066da5526607b1b624239a36f488fec861b4ab401"/]
<frame line="1" sqlhandle="0x02000000b4e2201f1eda6c0a562330100b742a51c5d4d9f1"/]
</executionStack]
<inputbuf]
select count(*) from employees where client_id=34273 and isadmin=1 </inputbuf]
</process]
</blocking-process]
</blocked-process-report]
Post #614570
Posted Friday, December 05, 2008 8:05 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Wednesday, February 19, 2014 11:15 AM
Points: 1,708, Visits: 1,790
Don,

Something happened to your report, but all that came through were the select statements. Can you repost the blocked process report?


Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
My Blog | Twitter | MVP Profile
Training | Consulting | Become a SQLskills Insider
Troubleshooting SQL Server: A Guide for Accidental DBAs
Post #614574
Posted Friday, December 05, 2008 8:23 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 7:22 AM
Points: 69, Visits: 770
Sorry, I edited my post. My xml was getting eaten when I posted so I replace the close ">" with right bracket "]"
Post #614594
Posted Monday, January 05, 2009 12:34 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Wednesday, February 19, 2014 11:15 AM
Points: 1,708, Visits: 1,790
Don,

Have you resolved this, and if not, what is the table/index definition for employees? Is there an index on the clientid column and what is the datatype for that column? Your blocked on a page, so I am guessing that you get lock escalation as a scan is occuring on the clustered index to find the rows that have the respective clientid's and that a index addition to the clientid column would resolve the problem. Can you post the execution plan of one of those statements?


Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
My Blog | Twitter | MVP Profile
Training | Consulting | Become a SQLskills Insider
Troubleshooting SQL Server: A Guide for Accidental DBAs
Post #630063
Posted Tuesday, January 06, 2009 2:44 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 7:22 AM
Points: 69, Visits: 770
Jonathan, thanks for looking at this. No, I haven't resolved it.

Client_Id is an integer column; there's an index on it:

CREATE NONCLUSTERED INDEX [Employees_Client_id] ON [dbo].[Employees]
(
[Client_ID] ASC,
[DivID] ASC,
[EmpID] ASC,
[Deleted] ASC
)

The query in question references both Client_Id and the bit column isadmin.

select count(*) from employees where client_id=11343 and isadmin=1

Since isadmin is not part of that index the query performs nested loop lookups of the clustered index. Here's the query plan.

|--Compute Scalar(DEFINE: ([Expr1003]=CONVERT_IMPLICIT(int,[Expr1008],0)))
|--Stream Aggregate(DEFINE: ([Expr1008]=Count(*)))
|--Filter(WHERE: ([phoenix].[dbo].[Employees].[IsAdmin]=(1)))
|--Nested Loops(Inner Join, OUTER REFERENCES: ([phoenix].[dbo].[Employees].[EmpID], [Expr1007]) WITH UNORDERED PREFETCH)
|--Index Seek(OBJECT: ([phoenix].[dbo].[Employees].[Employees_Client_id]), SEEK: ([phoenix].[dbo].[Employees].[Client_ID]=(11343)) ORDERED FORWARD)
|--Clustered Index Seek(OBJECT: ([phoenix].[dbo].[Employees].[PK_Employees]), SEEK: ([phoenix].[dbo].[Employees].[EmpID]=[phoenix].[dbo].[Employees].[EmpID]) LOOKUP ORDERED FORWARD)

I could add isadmin as an included column in the index which might or might not resolve the issue, but more importantly I want to understand just how one select query can block another. I didn't think that could happen. What could be getting locked?
Post #631046
Posted Wednesday, April 01, 2009 12:20 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, May 09, 2013 8:07 AM
Points: 1,221, Visits: 2,614
Thanks Jonathan. This one came in handy today.

Ken Simmons
http://twitter.com/KenSimmons
Post #688268
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse