Pages

Thursday 12 April 2012

SQL server: Deciphering Wait resource

When I was working with couple of frequent blocking issue in our live server, I have noticed different types of wait resources which are not meaningful unless they mapped to a table or an index. In this post I will explain how to map the wait resources to table/index.


Key Wait Resource 

Below is a sample of blocked process report with Key as wait resource .




The first part of the key wait resource is the database id and second part is called as Hobt_Id. Hobt is an acronym for Heap Or B Tree. The hobt_id can be mapped to sys.indexes and sys.objects through sys.partitions. Below script will map the key wait resource to corresponding index and table.

SELECT 
 o.name AS TableName
i.name AS IndexName,
SCHEMA_NAME(o.schema_id) AS SchemaName
FROM sys.partitions p JOIN sys.objects o ON p.OBJECT_ID = o.OBJECT_ID 
JOIN sys.indexes i ON p.OBJECT_ID = i.OBJECT_ID  AND p.index_id = i.index_id 
WHERE p.hobt_id = 72057594040811520

Page Wait Resource 

Below is a sample of blocked process report with Page as wait resource .

As everyone knows, the first part of the wait resource is the database id (68)  , second part is file id (1)  and third part is the page number(492478). To find out the object id associated with this page follow the below steps.

SELECT DB_NAME(68)
Select the database based on the output above statement. Then execute the below statement
DBCC traceon (3604)
GO
DBCC page (68, 1, 492478) --Database_id,file_id,page_id


This will give a result as given below.


The object id can be mapped to a table using  the system function  object_name()

Object Wait Resource 

Below is a sample of blocked process report with Object as wait resource .



Here also the first part of the wait resource is the database id(68) ,second part is the object id and third part is known as lock partition id. The object id part can be mapped to an object using the object_name() system function . The lock partition id is not very useful in troubleshooting the blocking issue.This will have positive value only when the server has more than 16 CPU. I will explain more about the lock partition in my  future post.

If you liked this post, do like my page on FaceBook at http://www.facebook.com/practicalSqlDba
















9 comments:

  1. I am fresher leaning SQL and this site has some very informative stuff! Sample Statements

    ReplyDelete
  2. Very nice. Thanks

    ReplyDelete
  3. This page has become a standard reference for me whenever investigating blocking and deadlocks. Thanks for your fine work :)

    ReplyDelete
  4. Hey, this article has helped a BUNCH! There are few things i do not understand in the blocked process report. However i cannot find any info on what XDES means and what it is telling me. Any ideas?

    ReplyDelete
  5. شركة تنظيف منازل بجدة
    شركة تنظيف منازل بمكة
    افضل شركة تنظيف بجدة
    شركة تنظيف خزانات بالمدينة المنورة
    شركة صيانة خزانات بجدة
    يحتاج الخزان إلى عناية متخصصة من تنظيف و تعقيم كل خمسة أشهر و هذا لن يتم إلا بالاستعانة بشركة تنظيف خزانات بجدة ولو انت في المدينة المنورة فتحتاج الى شركة غسيل خزانات بالمدينة وذلك لامتلاكهم السبل و الأساليب اللازمة لذلك كما أن لديهم خبراء و متخصصين في مجال تنظيف الخزانات بجدة و تنظيف الخزانات بالمدينة المنورة وتشمل العناية الآتي :
    عناية يدوية : عن طريق نزول العمال إلى الخزان و فركه جيدا و تنظيف جدرانه و الأسطح الخاصة به باستخدام المساحيق المنظفة الفعالة و اللازمة لهذه العملية .
    عناية ميكانيكية : عن طريق استخدام مكانس المياه و الخراطيم النفاسة لإزالة الرواسب و البكتريا . عندما يتواجد فتحة مناسبة يستطيع العمال الدخول إلى الخزان و تنظيفه جيدا من الداخل باستخدام فرشاة خشنة ثم ملأ المياه و تفريغها للتأكد من نظافته و في حالة الخزانات الصغيرة يتم الاكتفاء بتوجيه مكانس المياه أو مضخاتها إلى داخل الخزان لإزالة الأوساخ و الترسبات ثم ملأ و تفريغ المياه عدة مرات للتأكد من نظافته وذلك في شركة صيانة خزانات بجدة متميزة وخبرة

    ReplyDelete
  6. กับบริการที่สะดวก รวดเร็ว ครบวงจร ของ UFABET ไม่ว่าจะ ฝาก-ถอน สอบถามการใช้งานต่างๆ และสามารถวางเดิมพันได้ทุกที่ มีเกมพนันให้เลือกเล่นมากมาย UFA88WIN ยูฟ่า88วิน ตอบโจทย์คุณได้ดีที่สุด หมดปัญหาเรื่องการโดนโกง เพราะเราให้บริการตรงจากเว็บแม่ ยูฟ่าเบทประเทศไทย ปลอดภัย 100% รองรับการพนันบอลออนไลน์ ufa ผ่านอินเตอร์เน็ต และคาสิโนออนไลน์ที่มีให้เลือกมากกว่า 1000 เกมส์ ufa

    ReplyDelete
  7. People in San Marino speak the Italian language. The linguistic diversity of San Marino is almost homogeneous according to a fractionalization scale which for San Marino is 0. The followers of Christianity are the religious majority in the country. 94.1% of San Marino's population live in cities. This percentage comprises the urban population of San Marino. The rate of urbanization in San Marino is considered to be 0.9. According to data on inbound tourists in San Marino, 70,000 tourists arrive in the country each year. http://www.confiduss.com/en/jurisdictions/san-marino/culture/

    ReplyDelete