• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/78

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

78 Cards in this Set

  • Front
  • Back
LCK_M_BU
Occurs when a task is waiting to acquire a Bulk Update (BU) lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_IS
Occurs when a task is waiting to acquire an Intent Shared (IS) lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_IU
Occurs when a task is waiting to acquire an Intent Update (IU) lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_IX
Occurs when a task is waiting to acquire an Intent Exclusive (IX) lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RIn_NL
Occurs when a task is waiting to acquire a NULL lock on the current key value and an Insert Range lock between the current and previous key. A NULL lock on the key is an instant release lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RIn_S
Occurs when a task is waiting to acquire a shared lock on the current key value and an Insert Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RIn_U
Task is waiting to acquire an Update lock on the current key value and an Insert Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RIn_X
Occurs when a task is waiting to acquire an Exclusive lock on the current key value and an Insert Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RS_S
Occurs when a task is waiting to acquire a Shared lock on the current key value and a Shared Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RS_U
Occurs when a task is waiting to acquire an Update lock on the current key value and an Update Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RX_S
Occurs when a task is waiting to acquire a Shared lock on the current key value and an Exclusive Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RX_U
Occurs when a task is waiting to acquire an Update lock on the current key value and an Exclusive range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RX_X
Occurs when a task is waiting to acquire an Exclusive lock on the current key value and an Exclusive Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_S
Occurs when a task is waiting to acquire a Shared lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_SCH_M
Occurs when a task is waiting to acquire a Schema Modify lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_SCH_S
Occurs when a task is waiting to acquire a Schema Share lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_SIU
Occurs when a task is waiting to acquire a Shared With Intent Update lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_SIX
Occurs when a task is waiting to acquire a Shared With Intent Exclusive lock. For a lock compatibility matrix seesys.dm_tran_locks.
LCK_M_U
Occurs when a task is waiting to acquire an Update lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_UIX
Occurs when a task is waiting to acquire an Update With Intent Exclusive lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_X
Occurs when a task is waiting to acquire an Exclusive lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_BU
Occurs when a task is waiting to acquire a Bulk Update (BU) lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_IS
Occurs when a task is waiting to acquire an Intent Shared (IS) lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_IU
Occurs when a task is waiting to acquire an Intent Update (IU) lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_IX
Occurs when a task is waiting to acquire an Intent Exclusive (IX) lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RIn_NL
Occurs when a task is waiting to acquire a NULL lock on the current key value and an Insert Range lock between the current and previous key. A NULL lock on the key is an instant release lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RIn_S
Occurs when a task is waiting to acquire a shared lock on the current key value and an Insert Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RIn_U
Task is waiting to acquire an Update lock on the current key value and an Insert Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RIn_X
Occurs when a task is waiting to acquire an Exclusive lock on the current key value and an Insert Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RS_S
Occurs when a task is waiting to acquire a Shared lock on the current key value and a Shared Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RS_U
Occurs when a task is waiting to acquire an Update lock on the current key value and an Update Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RX_S
Occurs when a task is waiting to acquire a Shared lock on the current key value and an Exclusive Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RX_U
Occurs when a task is waiting to acquire an Update lock on the current key value and an Exclusive range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_RX_X
Occurs when a task is waiting to acquire an Exclusive lock on the current key value and an Exclusive Range lock between the current and previous key. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_S
Occurs when a task is waiting to acquire a Shared lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_SCH_M
Occurs when a task is waiting to acquire a Schema Modify lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_SCH_S
Occurs when a task is waiting to acquire a Schema Share lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_SIU
Occurs when a task is waiting to acquire a Shared With Intent Update lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_SIX
Occurs when a task is waiting to acquire a Shared With Intent Exclusive lock. For a lock compatibility matrix seesys.dm_tran_locks.
LCK_M_U
Occurs when a task is waiting to acquire an Update lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_UIX
Occurs when a task is waiting to acquire an Update With Intent Exclusive lock. For a lock compatibility matrix see sys.dm_tran_locks.
LCK_M_X
Occurs when a task is waiting to acquire an Exclusive lock. For a lock compatibility matrix see sys.dm_tran_locks.
Lock Granularity
Lock granularity refers to the level at which locks occur:

* Row
* Table
* Page
* Database
Locking
Locking is a mechanism used by the Microsoft SQL Server Database Engine to synchronize access by multiple users to the same piece of data at the same time.
Why is locking used?
To protect transactions against other transactions that might modify the same data.
Locking conflict rule:
No transaction can be granted a lock that would conflict with the mode of a lock already granted on that data to another transaction.
What happens when locking conflicts occur?
If a transaction requests a lock mode that conflicts with a lock that has already been granted on the same data, the instance of the Database Engine will pause the requesting transaction until the first lock is released.
How long are locks held for modifications?
When a transaction modifies a piece of data, it holds the lock protecting the modification until the end of the transaction.
How long will a transaction hold the locks acquired to protect read operations?
depends on the transaction isolation level setting.
When are locks released?
All locks held by a transaction are released when the transaction completes (either commits or rolls back).
How are locks normally requested.
Locks are managed internally by the query processor to the lock manager.
Lock Granularity and Hierarchies
Locks can be requested for different types of resources, such as rows, pages, indexes, tables, or databases. Some operations require placing locks at multiple levels of granularity, forming a hierarchy of locks.
Lock Modes
Locks have different modes that specify the level of access other transactions have to the locked resource.
Lock Compatibility (Database Engine)
Multiple transactions can acquire concurrent locks on the same resource if their lock modes are compatible. If a transaction requests a lock mode that conflicts with an existing lock, the transaction is paused until the first lock is freed.
Key-Range Locking
Locking a range of keys allows transactions running at the serializable isolation level to prevent phantom inserts and deletes.
Lock Escalation (Database Engine)
If a transaction acquires a large number of row or page locks, the Database Engine may grant a table lock and then free all the lower-level locks to minimize locking overhead.
Dynamic Locking
The Database Engine can dynamically choose the level of lock granularity based on the optimizer's estimate of the number of rows a Transact-SQL statement will reference.
Displaying Locking Information (Database Engine)
The Database Engine and its associated APIs provide several mechanisms for displaying information about the locks currently held in an instance or a database.
Deadlocking
Deadlocks occur when two tasks permanently block each other because each task has a lock on a resource needed by the other task.
Resources that can be locked (10)
RID - A row identifier used to lock a single row within a heap.

KEY - A row lock within an index used to protect key ranges in serializable transactions.

PAGE - An 8-kilobyte (KB) page in a database, such as data or index pages.

EXTENT - A contiguous group of eight pages, such as data or index pages.

HoBT - A heap or B-tree. A lock protecting a B-tree (index) or the heap data pages in a table that does not have a clustered index.

TABLE - The entire table, including all data and indexes.

FILE - A database file.

APPLICATION - An application-specified resource.

METADATA,
ALLOCATION_UNIT,
DATABASE
Lock Modes
Shared (S)
Update (U)
Exclusive (X)
Intent (IS), (IX), (SIX)
Schema (Sch-M), (Sch-S)
Bulk Update (BU)
Key-Range
Shared Lock Mode (S)
Used for read operations that do not change or update data, such as a SELECT statement.
Update Lock Mode (U)
Used on resources that can be updated. Prevents a common form of deadlock that occurs when multiple sessions are reading, locking, and potentially updating resources later.
Exclusive Lock Mode (X)
Used for data-modification operations, such as INSERT, UPDATE, or DELETE. Ensures that multiple updates cannot be made to the same resource at the same time.
Intent Lock Mode (IS), (IX), (SIX)
Used to establish a lock hierarchy. The types of intent locks are: intent shared (IS), intent exclusive (IX), and shared with intent exclusive (SIX).
Schema Lock Mode (Sch-M), (Sch-S)
Used when an operation dependent on the schema of a table is executing. The types of schema locks are: schema modification (Sch-M) and schema stability (Sch-S).
Bulk Update Lock Mode (BU)
Used when bulk copying data into a table and the TABLOCK hint is specified.
Key-range Lock Mode
Protects the range of rows read by a query when using the serializable transaction isolation level. Ensures that other transactions cannot insert rows that would qualify for the queries of the serializable transaction if the queries were run again.
Intent locks serve two purposes:
1. To prevent other transactions from modifying the higher-level resource in a way that would invalidate the lock at the lower level.

2. To improve the efficiency of the Database Engine in detecting lock conflicts at the higher level of granularity.
sys.dm_os_wait_stats
Returns information about the waits encountered by threads that executed. Does NOT show CURRENT waits but only the time for completed waits.
Types of Waits (3)
Resource Waits
Queue Waits
External Waits
Resource Waits
occur when a worker requests access to a resource that is not available because the resource is being used by some other worker or is not yet available.
Queue Waits
occur when a worker is idle, waiting for work to be assigned. These tasks will wait for work requests to be placed into a work queue.
Typical Queue Waits
Queue waits are most typically seen with system background tasks such as the deadlock monitor and deleted record cleanup tasks.

Queue waits may also periodically become active even if no new packets have been put on the queue.
Typical Resource Waits
Examples of resource waits are locks, latches, network and disk I/O waits. Lock and latch waits are waits on synchronization objects
External Waits
occur when a SQL Server worker is waiting for an external event, such as an extended stored procedure call or a linked server query, to finish.
External waits and blocking issues....
When you diagnose blocking issues, remember that external waits do not always imply that the worker is idle, because the worker may actively be running some external code.
How to reset sys.dm_os_wait_stats
DBCC SQLPERF ('sys.dm_os_wait_stats', CLEAR)
or when Server restarts