SlideShare a Scribd company logo
SQL Server Locking and Blocking
Hilary Cotter
Hilary.cotter@gmail.com
• Thought Experiment
• How can I tell if blocking is a problem?
• How SQL Server works
• Transactions
• Isolation models
• Dirty Reads & Repeatable reads
• Snapshot Isolation Levels
• Hints
• In Memory
• Monitoring
Agenda
Thought experiment
• How long does blocking last for?
• Forever
• 20 seconds
• Until the blocking process resolves
• Until the transaction completes
• Unpredictable
How SQL Server works
• WAL
• Checkpoint
• 4 ms Quanta/Timeslice - wait stats are logged
• Processors
– SELECT * from sys.dm_os_schedulers where status='VISIBLE ONLINE’
• MAXDOP
• Runnable queue
– select * from sys.dm_exec_requests where session_id >= 50 and session_id
<> @@spid and status=‘suspended’;
• Waiting queue
– select * from sys.dm_os_waiting_tasks
• Running queue
– select * from sys.dm_exec_requests where session_id >= 50 and session_id
<> @@spid and status='running’
How SQL Server works
• Wait your turn
• We call this blocking
• Serialized ownership
• We call this locking
• Concurrency
• maximizes users
• Goal of every RDBMS
How SQL Server works
• Protecting a row to provide serial access
• Think checking account/selling a limited resource
• Seats
• Shoes
• How long?
• Set Lock_Timeout 30000 ( process will give up after waiting 30s), -1
waits forever
How can I tell if locking is a
problem?
• Deadlocking
• Applications timing out
• Slow/sluggish/unpredictable performance
• Large numbers of lock escalations
• Most common wait types are LCK_M_<lock type>
• Select * from sys.sysprocesses where blocked<>0
order by waittime desc
• Sp_who2
• Sp_whoIsActive
• Data Access
– Always serial and in isolation
– Minimum level of granularity
– row basis
– too expensive to do column level locking
• Demo
• Visual Studio
Data Access
Transactions
• Unit of work
• Think checking account (debit one account,
credit another).
• Begin tran(saction), rollback tran(saction),
commit tran(saction)
• Implicit and explicit
Transactions – lost updates
• Beware of lost updates – history of column values is not recorded
• Select quantity_on_hand where pk=1
• 60
• --correct (two simultaneous sessions)
• Update stock set quantity_on_hand= quantity_on_hand-50
• Update stock set quantity_on_hand= quantity_on_hand-40 --
should be a >0 constraint
• --incorrect (two simultaneous sessions)
• Update stock set quantity_on_hand=10—sold 50 (session 1)
• Update stock set quantity_on_hand=20—sold 40 (session 2)
Transactions – lost updates
• --better
• Select quantity_on_hand, dtstamp where pk=1
• 60, 2017-02-10 14:46:14.410
• Begin tran
• Update stock set quantity_on_hand=quantity_on_hand-
50, dtstamp=getdate()
• And dtstamp=‘2017-02-10 14:46:14.410’—sold 50
• If @@Rowcount=0
• Begin
• Raiserror…
• Rollback tran
• end
Deadlocking
Two types of concurrency models
Pessimistic Optimistic
Use Case Competition for same resource Little competition for same resource
Think Ticket Sales Think Wikipedia
Writers block readers and vice versa Writers don’t block readers, readers
don’t block writes, writers block writers
(conflict)
Ugly tempdb contention
Hidden column
minimizes concurrency Need to handle conflicts
Optimistic vs Pessimistic
Optimistic is the default for Azure SQL Database, and
AlwaysON
Isolation Levels
Allows you to
control the level
of isolation of
your data from
other
processes
• How sensitive your application is to changes made
by other users' transactions
• How long SQL Server must hold locks to protect
against these changes
1) Read Committed (default)
2) Read Uncommitted (maximizes concurrency at the
cost of accuracy)
3) Repeatable Read (the same data has the same
values, but may see new data)
4) Serializable (the same data has the same values, do
not see new data)
Isolation Levels
Isolation Levels
Transaction
Isolation Level
Dirty Read Non-Repeatable
Read
Phantoms Blocks other
transactions
Concurrency
Model
Read
Uncommitted
Yes Yes Yes No Pessimistic
Read Committed No Yes Yes Yes Pessimistic
Read Committed
(RSCI)
No Yes Yes No Optimistic
Repeatable Read No No Yes Yes Pessimistic
Snapshot No No No No Optimistic
Serializable No No No Yes Pessimistic
Isolation Levels
Transaction Isolation Level Lock Behavior Table Hint
Read Uncommitted (S) locks are not acquired NOLOCK
Read Committed S) locks are acquired and
released immediately
READCOMMITTED
Repeatable Read (S) locks are held until the end
of transaction
REPEATABLEREAD
Serializable Range (S) locks are held until
the end of transaction
HOLDLOCK
READ COMMITTED
SNAPSHOT, SNAPSHOT
(S) locks are not acquired
(except for FK checks)
No
Dirty Reads
Dirty Reads
• WAL
• Transactions written to log
• Pages in buffer are dirtied
• On checkpoint dirty pages are hardened to disk
• On server restart – last checkpoint is consulted
• transactions committed in log, but not on disk
are replayed on data files
• transactions not committed in log, but on disk
are removed from data files.
• Key to this is that a dirty read will read dirty
pages in the buffer. Minimal locking is held
Dirty Reads – why is this bad?
• Maximizing concurrency – at the cost of
consistency
• Reading data in flight
• Demo 1 – data movement with failure
(Msg 601, Level 12, State 3, Line 1
• Could not continue scan with NOLOCK due to
data movement.)
• Problem 2 missing rows
• Problem 3 additional rows (phantoms)
RCSI vs Snapshot
RCSI Snapshot
High Concurrency High Concurrency
Variant of Read Committed Variant of Serializable
Absolute accuracy when query starts and single statement Absolute accuracy when query starts and multi-statement
Ideal for ledger queries/reports Ideal for long running transactions
Only writer/writer blocking Only writer/writer blocking
Optimistic Reads and Optimistic writes Optimistic reads and Pessimistic writes
You get conflicts
Sees data at the state the statement started Sees data at the state when the transaction started
ALTER DATABASE AdventureWorks
SET READ_COMMITTED_SNAPSHOT ON;
ALTER DATABASE AdventureWorks SET
ALLOW_SNAPSHOT_ISOLATION ON;
SET TRANSACTION ISOLATION
LEVEL SNAPSHOT
Locking
• Lock types – row, page, table, application
• Lock modes
• shared - reading
• exclusive (X, full)– writing. Held till the end of a transaction
• update – used to find data to lock exclusively, will convert to X
• intent – used to tell the data engine that a process is going to
modify data. Must find the data to modify and claims it.
• schema stability – ensures that the schema does not change
during data modification or reads
• BU – bulk update locks
•
Lock Modes
Requested Lock Mode Existing Granted Lock Mode
IS S U IX X
Intent Shared (IS) Yes Yes Yes Yes No
Shared (S) Yes Yes Yes No No
Update (U) Yes Yes Yes No No
Intent Exclusive(IX) Yes No No No Yes
Exclusive(X) No No No No No
Lock Compatibility –
if Yes access
if no wait.
Lock Modes
• Sch-S: schema stability lock
• Sch-M: schema modification lock
• Range Locks (LCK_M_Range*) - Protect
interval of the rows in SERIALIZABLE isolation
• BU: bulk update lock
Lock Escalation• Row
• Page
• Extent
• Table
Disabling lock escalation
• Deactivate the escalation for the server by using the Trace
Flags:
• 1211 – Disables Lock Escalation completely – allows to use
60% of the allocated memory – if 60% of memory is used and
more locking is needed you will get an out-of-memory error.
• 1224 – Disables Lock Escalation until the memory threshold
of 40% allocated memory is reached – after that Lock
Escalation is enabled.
• ALTER TABLE – table option:
• SET ( LOCK_ESCALATION = { AUTO | TABLE | DISABLE } )
• SQL 2008 and above
Monitoring
• Now:
• sys.dm_tran_locks– currently lock requests
and their statuses•
• sys.dm_os_waiting_tasks– wait_type
(LCK_M_*), blocking_session_id•
• sys.dm_exec_requests– wait_type
(LCK_M_*), blocking_session_id
• Later: Analyze blocked process report.
Monitoring
• Extended Events
• Event Notifications
In Memory
• Uses a lock free algorithm
• Writes minimal data to tlog
• Can be configured not to survive a restart
• Indexes are in main memory and not
persisted to disk
• Durability
– schema only
– schema and data
In Memory
• Uses a lock free algorithm
• Writes minimal data to tlog
• Can be configured not to survive a restart
• Indexes are in main memory and not
persisted to disk
• Durability schema only
• schema and data
Trouble shooting using WaitStats
•
• Consult sys.dm_db_index_operational_stats, look at lock_count,
lock_wait_count, lock_wait_ms on row and page levels, look at lock
escalation statistics.
Wait Type Cause
LCK_M_SCH_* Index and/or partition maintenance, frequent schema modifications (app
issues)
LCK_M_I* Lock escalation, schema modifications (see LCK_M_SCH*)
LCK_M_RS* SERIALIZABLE transactions, IGNORE_DUP_KEY option in NCI
LCK_M_U Nonoptimized DML queries. Perform query tuning. Analyze transaction
managemen
LCK_M_S Nonoptimized SELECT queries. Perform query tuning. Consider RCSI to
hide the problem.
Reducing locking
• Minimize indexes
• Avoid clustered indexes on frequently updated columns
• Monitor page splits
• Use covering indexes
• Partitioning a contended table
• Optimize the queries
• minimize the transaction length/footprint
• Reduce the isolation level
• Set LockTimeout
• --danger – may not rollback transaction
• Use set xabort on
• Check transaction state – if @@Trancount>0 rollback
• Snapshot isolation

More Related Content

What's hot

Using extended events for troubleshooting sql server
Using extended events for troubleshooting sql serverUsing extended events for troubleshooting sql server
Using extended events for troubleshooting sql server
Antonios Chatzipavlis
 
Liquibase få kontroll på dina databasförändringar
Liquibase   få kontroll på dina databasförändringarLiquibase   få kontroll på dina databasförändringar
Liquibase få kontroll på dina databasförändringar
Squeed
 
How many ways to monitor oracle golden gate - OOW14
How many ways to monitor oracle golden gate - OOW14How many ways to monitor oracle golden gate - OOW14
How many ways to monitor oracle golden gate - OOW14
Bobby Curtis
 
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document StoreConnector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
Filipe Silva
 
Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360
Carlos Sierra
 
Wait Watchers ; Gain SQL Performance Increases Fast!
Wait Watchers; Gain SQL Performance Increases Fast!Wait Watchers; Gain SQL Performance Increases Fast!
Wait Watchers ; Gain SQL Performance Increases Fast!
Richard Douglas
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOps
Andrei Solntsev
 
Oracle GoldenGate Studio Intro
Oracle GoldenGate Studio IntroOracle GoldenGate Studio Intro
Oracle GoldenGate Studio Intro
Bobby Curtis
 
Liquibase – a time machine for your data
Liquibase – a time machine for your dataLiquibase – a time machine for your data
Liquibase – a time machine for your data
Neev Technologies
 
10 Strategies for Developing Reliable Jakarta EE & MicroProfile Applications ...
10 Strategies for Developing Reliable Jakarta EE & MicroProfile Applications ...10 Strategies for Developing Reliable Jakarta EE & MicroProfile Applications ...
10 Strategies for Developing Reliable Jakarta EE & MicroProfile Applications ...
Payara
 
Sq lite presentation
Sq lite presentationSq lite presentation
Sq lite presentation
Prof. Erwin Globio
 
MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014
Ryusuke Kajiyama
 
Database versioning with liquibase
Database versioning with liquibaseDatabase versioning with liquibase
Database versioning with liquibase
Return on Intelligence
 
Road to database automation: database source control
Road to database automation: database source controlRoad to database automation: database source control
Road to database automation: database source control
Eduardo Piairo
 
The databases in SSDT: A work with project and best practices
The databases in SSDT: A work with project and best practicesThe databases in SSDT: A work with project and best practices
The databases in SSDT: A work with project and best practices
Kamil Nowinski
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum version
sqlserver.co.il
 
Li liq liqui liquibase
Li liq liqui liquibaseLi liq liqui liquibase
Li liq liqui liquibase
Yoram Michaeli
 
Liquibase case study
Liquibase case studyLiquibase case study
Liquibase case study
Vivek Dhayalan
 
Ultimate Free SQL Server Toolkit
Ultimate Free SQL Server ToolkitUltimate Free SQL Server Toolkit
Ultimate Free SQL Server Toolkit
Kevin Kline
 
Oracle OpenWorld 2016 Review - Focus on Data, BigData, Streaming Data, Machin...
Oracle OpenWorld 2016 Review - Focus on Data, BigData, Streaming Data, Machin...Oracle OpenWorld 2016 Review - Focus on Data, BigData, Streaming Data, Machin...
Oracle OpenWorld 2016 Review - Focus on Data, BigData, Streaming Data, Machin...
Lucas Jellema
 

What's hot (20)

Using extended events for troubleshooting sql server
Using extended events for troubleshooting sql serverUsing extended events for troubleshooting sql server
Using extended events for troubleshooting sql server
 
Liquibase få kontroll på dina databasförändringar
Liquibase   få kontroll på dina databasförändringarLiquibase   få kontroll på dina databasförändringar
Liquibase få kontroll på dina databasförändringar
 
How many ways to monitor oracle golden gate - OOW14
How many ways to monitor oracle golden gate - OOW14How many ways to monitor oracle golden gate - OOW14
How many ways to monitor oracle golden gate - OOW14
 
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document StoreConnector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
 
Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360
 
Wait Watchers ; Gain SQL Performance Increases Fast!
Wait Watchers; Gain SQL Performance Increases Fast!Wait Watchers; Gain SQL Performance Increases Fast!
Wait Watchers ; Gain SQL Performance Increases Fast!
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOps
 
Oracle GoldenGate Studio Intro
Oracle GoldenGate Studio IntroOracle GoldenGate Studio Intro
Oracle GoldenGate Studio Intro
 
Liquibase – a time machine for your data
Liquibase – a time machine for your dataLiquibase – a time machine for your data
Liquibase – a time machine for your data
 
10 Strategies for Developing Reliable Jakarta EE & MicroProfile Applications ...
10 Strategies for Developing Reliable Jakarta EE & MicroProfile Applications ...10 Strategies for Developing Reliable Jakarta EE & MicroProfile Applications ...
10 Strategies for Developing Reliable Jakarta EE & MicroProfile Applications ...
 
Sq lite presentation
Sq lite presentationSq lite presentation
Sq lite presentation
 
MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014
 
Database versioning with liquibase
Database versioning with liquibaseDatabase versioning with liquibase
Database versioning with liquibase
 
Road to database automation: database source control
Road to database automation: database source controlRoad to database automation: database source control
Road to database automation: database source control
 
The databases in SSDT: A work with project and best practices
The databases in SSDT: A work with project and best practicesThe databases in SSDT: A work with project and best practices
The databases in SSDT: A work with project and best practices
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum version
 
Li liq liqui liquibase
Li liq liqui liquibaseLi liq liqui liquibase
Li liq liqui liquibase
 
Liquibase case study
Liquibase case studyLiquibase case study
Liquibase case study
 
Ultimate Free SQL Server Toolkit
Ultimate Free SQL Server ToolkitUltimate Free SQL Server Toolkit
Ultimate Free SQL Server Toolkit
 
Oracle OpenWorld 2016 Review - Focus on Data, BigData, Streaming Data, Machin...
Oracle OpenWorld 2016 Review - Focus on Data, BigData, Streaming Data, Machin...Oracle OpenWorld 2016 Review - Focus on Data, BigData, Streaming Data, Machin...
Oracle OpenWorld 2016 Review - Focus on Data, BigData, Streaming Data, Machin...
 

Similar to Geek Sync | How to Detect, Analyze, and Minimize SQL Server Blocking and Locking

Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACPerformance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Kristofferson A
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
Boris Hristov
 
Strategic autovacuum
Strategic autovacuumStrategic autovacuum
Strategic autovacuum
Jim Mlodgenski
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Bob Pusateri
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Bob Pusateri
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Bob Pusateri
 
What are you waiting for
What are you waiting forWhat are you waiting for
What are you waiting for
Jason Strate
 
Strategic Autovacuum
Strategic AutovacuumStrategic Autovacuum
Strategic Autovacuum
Scott Mead
 
SQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should KnowSQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should Know
Dean Richards
 
Analyzing and Interpreting AWR
Analyzing and Interpreting AWRAnalyzing and Interpreting AWR
Analyzing and Interpreting AWR
pasalapudi
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
Boris Hristov
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
Boris Hristov
 
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
Lucas Jellema
 
Backing Up and Recovery
Backing Up and RecoveryBacking Up and Recovery
Backing Up and Recovery
Maham Huda
 
Aioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_features
AiougVizagChapter
 
Day 7 - Make it Fast
Day 7 - Make it FastDay 7 - Make it Fast
Day 7 - Make it Fast
Barry Jones
 
Alibaba patches in MariaDB
Alibaba patches in MariaDBAlibaba patches in MariaDB
Alibaba patches in MariaDB
Lixun Peng
 
ScaleDB Technical Presentation
ScaleDB Technical PresentationScaleDB Technical Presentation
ScaleDB Technical Presentation
Ivan Zoratti
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL Server
Kevin Kline
 
Swift at Scale: The IBM SoftLayer Story
Swift at Scale: The IBM SoftLayer StorySwift at Scale: The IBM SoftLayer Story
Swift at Scale: The IBM SoftLayer Story
Brian Cline
 

Similar to Geek Sync | How to Detect, Analyze, and Minimize SQL Server Blocking and Locking (20)

Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACPerformance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
 
Strategic autovacuum
Strategic autovacuumStrategic autovacuum
Strategic autovacuum
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
 
What are you waiting for
What are you waiting forWhat are you waiting for
What are you waiting for
 
Strategic Autovacuum
Strategic AutovacuumStrategic Autovacuum
Strategic Autovacuum
 
SQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should KnowSQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should Know
 
Analyzing and Interpreting AWR
Analyzing and Interpreting AWRAnalyzing and Interpreting AWR
Analyzing and Interpreting AWR
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
 
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
 
Backing Up and Recovery
Backing Up and RecoveryBacking Up and Recovery
Backing Up and Recovery
 
Aioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_features
 
Day 7 - Make it Fast
Day 7 - Make it FastDay 7 - Make it Fast
Day 7 - Make it Fast
 
Alibaba patches in MariaDB
Alibaba patches in MariaDBAlibaba patches in MariaDB
Alibaba patches in MariaDB
 
ScaleDB Technical Presentation
ScaleDB Technical PresentationScaleDB Technical Presentation
ScaleDB Technical Presentation
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL Server
 
Swift at Scale: The IBM SoftLayer Story
Swift at Scale: The IBM SoftLayer StorySwift at Scale: The IBM SoftLayer Story
Swift at Scale: The IBM SoftLayer Story
 

More from IDERA Software

The role of the database administrator (DBA) in 2020: Changes, challenges, an...
The role of the database administrator (DBA) in 2020: Changes, challenges, an...The role of the database administrator (DBA) in 2020: Changes, challenges, an...
The role of the database administrator (DBA) in 2020: Changes, challenges, an...
IDERA Software
 
Problems and solutions for migrating databases to the cloud
Problems and solutions for migrating databases to the cloudProblems and solutions for migrating databases to the cloud
Problems and solutions for migrating databases to the cloud
IDERA Software
 
Public cloud uses and limitations
Public cloud uses and limitationsPublic cloud uses and limitations
Public cloud uses and limitations
IDERA Software
 
Optimize the performance, cost, and value of databases.pptx
Optimize the performance, cost, and value of databases.pptxOptimize the performance, cost, and value of databases.pptx
Optimize the performance, cost, and value of databases.pptx
IDERA Software
 
Monitor cloud database with SQL Diagnostic Manager for SQL Server
Monitor cloud database with SQL Diagnostic Manager for SQL ServerMonitor cloud database with SQL Diagnostic Manager for SQL Server
Monitor cloud database with SQL Diagnostic Manager for SQL Server
IDERA Software
 
Database administrators (dbas) face increasing pressure to monitor databases
Database administrators (dbas) face increasing pressure to monitor databasesDatabase administrators (dbas) face increasing pressure to monitor databases
Database administrators (dbas) face increasing pressure to monitor databases
IDERA Software
 
Six tips for cutting sql server licensing costs
Six tips for cutting sql server licensing costsSix tips for cutting sql server licensing costs
Six tips for cutting sql server licensing costs
IDERA Software
 
Idera live 2021: The Power of Abstraction by Steve Hoberman
Idera live 2021:  The Power of Abstraction by Steve HobermanIdera live 2021:  The Power of Abstraction by Steve Hoberman
Idera live 2021: The Power of Abstraction by Steve Hoberman
IDERA Software
 
Idera live 2021: Why Data Lakes are Critical for AI, ML, and IoT By Brian Flug
Idera live 2021:  Why Data Lakes are Critical for AI, ML, and IoT  By Brian FlugIdera live 2021:  Why Data Lakes are Critical for AI, ML, and IoT  By Brian Flug
Idera live 2021: Why Data Lakes are Critical for AI, ML, and IoT By Brian Flug
IDERA Software
 
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
IDERA Software
 
Idera live 2021: Managing Digital Transformation on a Budget by Bert Scalzo
Idera live 2021:  Managing Digital Transformation on a Budget by Bert ScalzoIdera live 2021:  Managing Digital Transformation on a Budget by Bert Scalzo
Idera live 2021: Managing Digital Transformation on a Budget by Bert Scalzo
IDERA Software
 
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
IDERA Software
 
Idera live 2021: Managing Databases in the Cloud - the First Step, a Succes...
Idera live 2021:   Managing Databases in the Cloud - the First Step, a Succes...Idera live 2021:   Managing Databases in the Cloud - the First Step, a Succes...
Idera live 2021: Managing Databases in the Cloud - the First Step, a Succes...
IDERA Software
 
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
IDERA Software
 
Idera live 2021: Performance Tuning Azure SQL Database by Monica Rathbun
Idera live 2021:  Performance Tuning Azure SQL Database by Monica RathbunIdera live 2021:  Performance Tuning Azure SQL Database by Monica Rathbun
Idera live 2021: Performance Tuning Azure SQL Database by Monica Rathbun
IDERA Software
 
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERAGeek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
IDERA Software
 
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
IDERA Software
 
Benefits of Third Party Tools for MySQL | IDERA
Benefits of Third Party Tools for MySQL | IDERABenefits of Third Party Tools for MySQL | IDERA
Benefits of Third Party Tools for MySQL | IDERA
IDERA Software
 
Achieve More with Less Resources | IDERA
Achieve More with Less Resources | IDERAAchieve More with Less Resources | IDERA
Achieve More with Less Resources | IDERA
IDERA Software
 
Benefits of SQL Server 2017 and 2019 | IDERA
Benefits of SQL Server 2017 and 2019 | IDERABenefits of SQL Server 2017 and 2019 | IDERA
Benefits of SQL Server 2017 and 2019 | IDERA
IDERA Software
 

More from IDERA Software (20)

The role of the database administrator (DBA) in 2020: Changes, challenges, an...
The role of the database administrator (DBA) in 2020: Changes, challenges, an...The role of the database administrator (DBA) in 2020: Changes, challenges, an...
The role of the database administrator (DBA) in 2020: Changes, challenges, an...
 
Problems and solutions for migrating databases to the cloud
Problems and solutions for migrating databases to the cloudProblems and solutions for migrating databases to the cloud
Problems and solutions for migrating databases to the cloud
 
Public cloud uses and limitations
Public cloud uses and limitationsPublic cloud uses and limitations
Public cloud uses and limitations
 
Optimize the performance, cost, and value of databases.pptx
Optimize the performance, cost, and value of databases.pptxOptimize the performance, cost, and value of databases.pptx
Optimize the performance, cost, and value of databases.pptx
 
Monitor cloud database with SQL Diagnostic Manager for SQL Server
Monitor cloud database with SQL Diagnostic Manager for SQL ServerMonitor cloud database with SQL Diagnostic Manager for SQL Server
Monitor cloud database with SQL Diagnostic Manager for SQL Server
 
Database administrators (dbas) face increasing pressure to monitor databases
Database administrators (dbas) face increasing pressure to monitor databasesDatabase administrators (dbas) face increasing pressure to monitor databases
Database administrators (dbas) face increasing pressure to monitor databases
 
Six tips for cutting sql server licensing costs
Six tips for cutting sql server licensing costsSix tips for cutting sql server licensing costs
Six tips for cutting sql server licensing costs
 
Idera live 2021: The Power of Abstraction by Steve Hoberman
Idera live 2021:  The Power of Abstraction by Steve HobermanIdera live 2021:  The Power of Abstraction by Steve Hoberman
Idera live 2021: The Power of Abstraction by Steve Hoberman
 
Idera live 2021: Why Data Lakes are Critical for AI, ML, and IoT By Brian Flug
Idera live 2021:  Why Data Lakes are Critical for AI, ML, and IoT  By Brian FlugIdera live 2021:  Why Data Lakes are Critical for AI, ML, and IoT  By Brian Flug
Idera live 2021: Why Data Lakes are Critical for AI, ML, and IoT By Brian Flug
 
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
 
Idera live 2021: Managing Digital Transformation on a Budget by Bert Scalzo
Idera live 2021:  Managing Digital Transformation on a Budget by Bert ScalzoIdera live 2021:  Managing Digital Transformation on a Budget by Bert Scalzo
Idera live 2021: Managing Digital Transformation on a Budget by Bert Scalzo
 
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
 
Idera live 2021: Managing Databases in the Cloud - the First Step, a Succes...
Idera live 2021:   Managing Databases in the Cloud - the First Step, a Succes...Idera live 2021:   Managing Databases in the Cloud - the First Step, a Succes...
Idera live 2021: Managing Databases in the Cloud - the First Step, a Succes...
 
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
 
Idera live 2021: Performance Tuning Azure SQL Database by Monica Rathbun
Idera live 2021:  Performance Tuning Azure SQL Database by Monica RathbunIdera live 2021:  Performance Tuning Azure SQL Database by Monica Rathbun
Idera live 2021: Performance Tuning Azure SQL Database by Monica Rathbun
 
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERAGeek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
 
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
 
Benefits of Third Party Tools for MySQL | IDERA
Benefits of Third Party Tools for MySQL | IDERABenefits of Third Party Tools for MySQL | IDERA
Benefits of Third Party Tools for MySQL | IDERA
 
Achieve More with Less Resources | IDERA
Achieve More with Less Resources | IDERAAchieve More with Less Resources | IDERA
Achieve More with Less Resources | IDERA
 
Benefits of SQL Server 2017 and 2019 | IDERA
Benefits of SQL Server 2017 and 2019 | IDERABenefits of SQL Server 2017 and 2019 | IDERA
Benefits of SQL Server 2017 and 2019 | IDERA
 

Recently uploaded

Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 

Recently uploaded (20)

Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 

Geek Sync | How to Detect, Analyze, and Minimize SQL Server Blocking and Locking

  • 1. SQL Server Locking and Blocking Hilary Cotter Hilary.cotter@gmail.com
  • 2. • Thought Experiment • How can I tell if blocking is a problem? • How SQL Server works • Transactions • Isolation models • Dirty Reads & Repeatable reads • Snapshot Isolation Levels • Hints • In Memory • Monitoring Agenda
  • 3. Thought experiment • How long does blocking last for? • Forever • 20 seconds • Until the blocking process resolves • Until the transaction completes • Unpredictable
  • 4. How SQL Server works • WAL • Checkpoint • 4 ms Quanta/Timeslice - wait stats are logged • Processors – SELECT * from sys.dm_os_schedulers where status='VISIBLE ONLINE’ • MAXDOP • Runnable queue – select * from sys.dm_exec_requests where session_id >= 50 and session_id <> @@spid and status=‘suspended’; • Waiting queue – select * from sys.dm_os_waiting_tasks • Running queue – select * from sys.dm_exec_requests where session_id >= 50 and session_id <> @@spid and status='running’
  • 5. How SQL Server works • Wait your turn • We call this blocking • Serialized ownership • We call this locking • Concurrency • maximizes users • Goal of every RDBMS
  • 6. How SQL Server works • Protecting a row to provide serial access • Think checking account/selling a limited resource • Seats • Shoes • How long? • Set Lock_Timeout 30000 ( process will give up after waiting 30s), -1 waits forever
  • 7. How can I tell if locking is a problem? • Deadlocking • Applications timing out • Slow/sluggish/unpredictable performance • Large numbers of lock escalations • Most common wait types are LCK_M_<lock type> • Select * from sys.sysprocesses where blocked<>0 order by waittime desc • Sp_who2 • Sp_whoIsActive
  • 8. • Data Access – Always serial and in isolation – Minimum level of granularity – row basis – too expensive to do column level locking • Demo • Visual Studio Data Access
  • 9. Transactions • Unit of work • Think checking account (debit one account, credit another). • Begin tran(saction), rollback tran(saction), commit tran(saction) • Implicit and explicit
  • 10. Transactions – lost updates • Beware of lost updates – history of column values is not recorded • Select quantity_on_hand where pk=1 • 60 • --correct (two simultaneous sessions) • Update stock set quantity_on_hand= quantity_on_hand-50 • Update stock set quantity_on_hand= quantity_on_hand-40 -- should be a >0 constraint • --incorrect (two simultaneous sessions) • Update stock set quantity_on_hand=10—sold 50 (session 1) • Update stock set quantity_on_hand=20—sold 40 (session 2)
  • 11. Transactions – lost updates • --better • Select quantity_on_hand, dtstamp where pk=1 • 60, 2017-02-10 14:46:14.410 • Begin tran • Update stock set quantity_on_hand=quantity_on_hand- 50, dtstamp=getdate() • And dtstamp=‘2017-02-10 14:46:14.410’—sold 50 • If @@Rowcount=0 • Begin • Raiserror… • Rollback tran • end
  • 13. Two types of concurrency models
  • 14. Pessimistic Optimistic Use Case Competition for same resource Little competition for same resource Think Ticket Sales Think Wikipedia Writers block readers and vice versa Writers don’t block readers, readers don’t block writes, writers block writers (conflict) Ugly tempdb contention Hidden column minimizes concurrency Need to handle conflicts Optimistic vs Pessimistic Optimistic is the default for Azure SQL Database, and AlwaysON
  • 15. Isolation Levels Allows you to control the level of isolation of your data from other processes
  • 16. • How sensitive your application is to changes made by other users' transactions • How long SQL Server must hold locks to protect against these changes 1) Read Committed (default) 2) Read Uncommitted (maximizes concurrency at the cost of accuracy) 3) Repeatable Read (the same data has the same values, but may see new data) 4) Serializable (the same data has the same values, do not see new data) Isolation Levels
  • 17. Isolation Levels Transaction Isolation Level Dirty Read Non-Repeatable Read Phantoms Blocks other transactions Concurrency Model Read Uncommitted Yes Yes Yes No Pessimistic Read Committed No Yes Yes Yes Pessimistic Read Committed (RSCI) No Yes Yes No Optimistic Repeatable Read No No Yes Yes Pessimistic Snapshot No No No No Optimistic Serializable No No No Yes Pessimistic
  • 18. Isolation Levels Transaction Isolation Level Lock Behavior Table Hint Read Uncommitted (S) locks are not acquired NOLOCK Read Committed S) locks are acquired and released immediately READCOMMITTED Repeatable Read (S) locks are held until the end of transaction REPEATABLEREAD Serializable Range (S) locks are held until the end of transaction HOLDLOCK READ COMMITTED SNAPSHOT, SNAPSHOT (S) locks are not acquired (except for FK checks) No
  • 20. Dirty Reads • WAL • Transactions written to log • Pages in buffer are dirtied • On checkpoint dirty pages are hardened to disk • On server restart – last checkpoint is consulted • transactions committed in log, but not on disk are replayed on data files • transactions not committed in log, but on disk are removed from data files. • Key to this is that a dirty read will read dirty pages in the buffer. Minimal locking is held
  • 21. Dirty Reads – why is this bad? • Maximizing concurrency – at the cost of consistency • Reading data in flight • Demo 1 – data movement with failure (Msg 601, Level 12, State 3, Line 1 • Could not continue scan with NOLOCK due to data movement.) • Problem 2 missing rows • Problem 3 additional rows (phantoms)
  • 22. RCSI vs Snapshot RCSI Snapshot High Concurrency High Concurrency Variant of Read Committed Variant of Serializable Absolute accuracy when query starts and single statement Absolute accuracy when query starts and multi-statement Ideal for ledger queries/reports Ideal for long running transactions Only writer/writer blocking Only writer/writer blocking Optimistic Reads and Optimistic writes Optimistic reads and Pessimistic writes You get conflicts Sees data at the state the statement started Sees data at the state when the transaction started ALTER DATABASE AdventureWorks SET READ_COMMITTED_SNAPSHOT ON; ALTER DATABASE AdventureWorks SET ALLOW_SNAPSHOT_ISOLATION ON; SET TRANSACTION ISOLATION LEVEL SNAPSHOT
  • 23. Locking • Lock types – row, page, table, application • Lock modes • shared - reading • exclusive (X, full)– writing. Held till the end of a transaction • update – used to find data to lock exclusively, will convert to X • intent – used to tell the data engine that a process is going to modify data. Must find the data to modify and claims it. • schema stability – ensures that the schema does not change during data modification or reads • BU – bulk update locks •
  • 24. Lock Modes Requested Lock Mode Existing Granted Lock Mode IS S U IX X Intent Shared (IS) Yes Yes Yes Yes No Shared (S) Yes Yes Yes No No Update (U) Yes Yes Yes No No Intent Exclusive(IX) Yes No No No Yes Exclusive(X) No No No No No Lock Compatibility – if Yes access if no wait.
  • 25. Lock Modes • Sch-S: schema stability lock • Sch-M: schema modification lock • Range Locks (LCK_M_Range*) - Protect interval of the rows in SERIALIZABLE isolation • BU: bulk update lock
  • 26. Lock Escalation• Row • Page • Extent • Table
  • 27. Disabling lock escalation • Deactivate the escalation for the server by using the Trace Flags: • 1211 – Disables Lock Escalation completely – allows to use 60% of the allocated memory – if 60% of memory is used and more locking is needed you will get an out-of-memory error. • 1224 – Disables Lock Escalation until the memory threshold of 40% allocated memory is reached – after that Lock Escalation is enabled. • ALTER TABLE – table option: • SET ( LOCK_ESCALATION = { AUTO | TABLE | DISABLE } ) • SQL 2008 and above
  • 28. Monitoring • Now: • sys.dm_tran_locks– currently lock requests and their statuses• • sys.dm_os_waiting_tasks– wait_type (LCK_M_*), blocking_session_id• • sys.dm_exec_requests– wait_type (LCK_M_*), blocking_session_id • Later: Analyze blocked process report.
  • 29. Monitoring • Extended Events • Event Notifications
  • 30. In Memory • Uses a lock free algorithm • Writes minimal data to tlog • Can be configured not to survive a restart • Indexes are in main memory and not persisted to disk • Durability – schema only – schema and data
  • 31. In Memory • Uses a lock free algorithm • Writes minimal data to tlog • Can be configured not to survive a restart • Indexes are in main memory and not persisted to disk • Durability schema only • schema and data
  • 32. Trouble shooting using WaitStats • • Consult sys.dm_db_index_operational_stats, look at lock_count, lock_wait_count, lock_wait_ms on row and page levels, look at lock escalation statistics. Wait Type Cause LCK_M_SCH_* Index and/or partition maintenance, frequent schema modifications (app issues) LCK_M_I* Lock escalation, schema modifications (see LCK_M_SCH*) LCK_M_RS* SERIALIZABLE transactions, IGNORE_DUP_KEY option in NCI LCK_M_U Nonoptimized DML queries. Perform query tuning. Analyze transaction managemen LCK_M_S Nonoptimized SELECT queries. Perform query tuning. Consider RCSI to hide the problem.
  • 33. Reducing locking • Minimize indexes • Avoid clustered indexes on frequently updated columns • Monitor page splits • Use covering indexes • Partitioning a contended table • Optimize the queries • minimize the transaction length/footprint • Reduce the isolation level • Set LockTimeout • --danger – may not rollback transaction • Use set xabort on • Check transaction state – if @@Trancount>0 rollback • Snapshot isolation