30.06.2013 Views

Performance Tuning with SQL Server Dynamic Management Views

Performance Tuning with SQL Server Dynamic Management Views

Performance Tuning with SQL Server Dynamic Management Views

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

125<br />

Chapter 4: Transactions<br />

• Shared (S) – shared locks are issued for read-only operations, such as SELECT<br />

statements. They prevent other transactions from updating the same data while the<br />

query is processing. Multiple shared locks can be issued for the same resource, hence<br />

the term "shared."<br />

• Update (U) – update locks prevent data being modified by another transaction in the<br />

time between finding the data that needs to be updated, and actually modifying it.<br />

A U lock is obtained while the data is located, and then this is converted to an<br />

exclusive lock to perform the update. Only a single update lock can be issued<br />

for a given resource, and it must be converted to an exclusive lock before a data<br />

modification can occur.<br />

• Exclusive (X) – exclusive locks are used for data modification requests (INSERT,<br />

UPDATE, and DELETE) to ensure that multiple updates do not occur against the<br />

same resource. Only a single exclusive lock can be placed on a resource at any given<br />

point in time. This prevents any other transaction from reading or modifying the<br />

X-locked data.<br />

• Intent (IX, IU, IS) – intent locks, as their name suggest, indicate an intention to lock<br />

a resource lower in the locking hierarchy. So, for example, immediately before<br />

obtaining an S lock on a row in a table, <strong>SQL</strong> <strong>Server</strong> will briefly obtain an Intent<br />

Shared (IS) lock on the table (or page), which will prevent another transaction from<br />

obtaining an exclusive lock on the table. Other types of intent lock are Intent Exclusive<br />

(IX) and Intent Update (IU). All intent locks can be acquired only on pages and tables.<br />

If an X lock is obtained on a key column, then both the page and the table associated<br />

<strong>with</strong> that key would be assigned an IX lock.<br />

• Conversion – these locks are the result of conversion from one locking mode to<br />

another. There are three types of conversion lock:<br />

• (SIX) – Shared <strong>with</strong> Intent Exclusive – a transaction currently holds a shared (S)<br />

lock on a resource, then subsequently needs to obtain an exclusive (X) lock on a<br />

component of the resource that is S locked

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!