Download presentation
Presentation is loading. Please wait.
1
A Masters view on Locking and blocking
Mikael Wedham A Masters view on Locking and blocking
2
Thank you to our AWESOME sponsors!
3
Mikael Wedham Microsoft Certified Master Trainer Developer Database Administrator Solution Developer Systems Engineer and so on… Växjö,
4
Locking, the problem Reading, sometimes Writing Multiple writes Consistent analysis DEMO: Classic lock.
5
Finding the issue - with sys.dm_os_wait_stats
The hard way: Write your own The easy way: DEMO…
6
Finding lock details sp_lock sp_who sp_who2 OR more ”modern” sys.dm_tran_locks sys.dm_exec_sessions
7
Transactions A C I D
8
Transactions Always Check It, Dumba$$
9
Transactions Atomicity Consistency Isolation Durability
10
Isolation levels Different transaction levels for different cases
Reads set Shared (S) locks Writes set Exclusive (X) locks Busy Writes sets Update (U) locks, transitions to (X) when alone Check BOL for compatibility matrix
11
READ COMMITTED (default)
All reads occur on commited data. Two identical SELECT statements, even when encapsulated in a transaction, can return different data.
12
READ UNCOMMITTED Catastrophic, due to data movement mid-select.
Reads without honoring locks. Problem because rows are not committed Bigger problem because data may be inconsistent Catastrophic, due to data movement mid-select.
13
REPEATABLE READ Locks read data until end of transaction. All read rows will stay the same New rows can appear
14
SERIALIZABLE All rows and their ”before” and ”after” rows are locked. Prevents new rows from being inserted.
15
ALLOW SNAPSHOT Turning it on makes all the difference in performance
READ COMMITTED SNAPSHOT Changes only Reads. Requires no code change TRANSACTION ISOLATION LEVEL SNAPSHOT Must be set – and coded for.
16
SNAPSHOT DEMO
17
InMemory tables Uses row-versioning similar to snapshot. DEMO
18
Thoughts about solutions for blocking…
Short(er) transactions Snapshot In-Memory OLTP Read-only copy ”Real” BI
19
Thoughts about solutions for blocking…
Short(er) transactions Snapshot In-Memory OLTP Read-only copy ”Real” BI Questions??
20
Thank You for listening!
Mikael
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.