top of page

Lock Events Category

While the current 70-762 Exam Ref "Developing SQL Databases" emphasizes that using Extended Events is an efficient way to tackle locking issues. However, the book did not go very deep in this topic. Fortunately, there are several good resources online:

https://docs.microsoft.com/en-us/sql/relational-databases/event-classes/locks-event-category?view=sql-server-ver15

https://docs.microsoft.com/en-us/analysis-services/trace-events/lock-events-category?view=asallproducts-allversions

 

Use the event classes in the Locks event category to monitor locking activity in an instance of the Microsoft SQL Server Database Engine. These event classes can help you investigate locking problems caused by multiple users reading and modifying data concurrently.

Because the Database Engine often processes many locks, capturing the Locks event classes during a trace can incur significant overhead and result in large trace files or tables. The Locks Events event category has the event classes described in the following table. The following is a summary,

 

Example:

You are developing an application that connects to a database. The application runs the following jobs:

The READ_COMMITTED_SNAPSHOT database option is set to OFF, and auto-content is set to ON. Within the stored procedures, no explicit transactions are defined.

If JobB starts before JobA, it can finish in seconds. If JobA starts first, JobB takes a long time to complete.

You need to use Microsoft SQL Server Profiler to determine whether the blocking that you observe in JobB is caused by locks acquired by JobA. Which trace event class in the Locks event category should you use?

  • A. LockAcquired

  • B. LockCancel

  • C. LockDeadlock

  • D. LockEscalation

Correct Answer: A

The Lock:Acquired event class indicates that acquisition of a lock on a resource, such asa data page, has been achieved.

The Lock:Acquired and Lock:Released event classes can be used to monitor when objects are being locked, the type of locks taken, and for how long the locks were retained. Locks retained for long periods of time may cause contention issues and should be investigated.

aboutME

I am John Fan Zhang, a data analyst and finance researcher. I hold a PhD in finance, CFA charter and full membership of CFA New Zealand Society. I have fifteen-year experience in corporate investment and eight-year experience in advanced data analysis. My research focuses on the effect of social psychology (culture) on financial decisions. Finance research involves heaps of data analyses that lead me to the data field. I am a Microsoft Certified Solutions Expert (MCSE): Data Management and Analytics (Excel, Power BI, and SQL). Aside from Excel, Power BI and SQL, I am also familiar with econometric tools such as Stata, Eviews, and MATLAB. I use OX and Python for programming. I am an active data community event participant, volunteer, speaker, moderator, program reviewer, including PASS Marathon 2020, Global AI BootCamp Auckland 2019, SQL Saturday Auckland (2017, 2018, 2019), and Definity Conference (2018, 2019, 2020, Auckland, New Zealand).

Auckland, New Zealand

  • Google Site
  • Twitter
  • LinkedIn

©2016 BY JOHN'S DATA STORY

bottom of page