Download presentation
Presentation is loading. Please wait.
1
Batches, Transactions, & Errors
John Deardurff Website: December 12, 2015
2
Presentation Topics How Queries are Processed Types of Errors
Working with Batches ACID Transactions Explicit Transactions Error Handling
3
Parse Resolve Optimize Compile Execute Execute SQL Sets Ad Hoc Query
Stored Procedure Syntax Parse Execution Context Resolve Compile Optimize Execution Plan Procedure Cache Compile Run Time Execute Execute SQL Sets
4
Working with Batches
5
VS Batches vs. Transactions Batches Transactions TSQL2012.mdf
Sends Code to the Processor Sends Data to the Database
6
Batches And Variables First Batch Successful Second Batch Fails
7
Transactions must pass the ACID test
Atomicity – All or Nothing Consistent – Only valid data Isolated – No interference Durable – Data is recoverable
8
Transaction Recovery Transaction Recovery Action Required 1 None 2
Roll forward 3 Roll back 4 Roll forward 5 Roll back Checkpoint System Failure
9
Auto Commit Transactions without Error Handling
TSQL2012.ldf Checkpoint TSQL2012.mdf
10
Explicit Transactions without Error Handling
TSQL2012.ldf Checkpoint TSQL2012.mdf
11
Explicit Transactions with Error Handling
TSQL2012.ldf TSQL2012.mdf Checkpoint
12
What are Locks? Transaction 1 Transaction 2 TSQL2012.mdf
13
Module 13: Creating Highly Concurrent SQL Server 2012 Applications
Course 10776A What Problems does Locking Prevent? Module 13: Creating Highly Concurrent SQL Server 2012 Applications Lost Updates Uncommitted dependency (dirty read) Inconsistent analysis (non-repeatable reads) Phantom reads Question: Has your organization experienced concurrency problems with database applications? If so, what behavior did you see? Answer: Answers will vary. References: Concurrency Problems: Concurrency Effects: Locking in the Database Engine:
14
Lost Update Original value of 125. The second session is unaware of the first sessions update.
15
Uncommitted dependency (dirty read)
Clean Read Dirty Read
16
Inconsistent analysis (non-repeatable read)
Change Isolation Level to Repeatable Read
17
Phantom Reads – (Demo Setup)
Added 3 columns for demo
18
Phantom Reads Missing record 18
19
Transaction Isolation Levels
20
Module 13: Creating Highly Concurrent SQL Server 2012 Applications
Course 10776A Transaction Isolation Levels Module 13: Creating Highly Concurrent SQL Server 2012 Applications Isolation Level Dirty Read Lost Update Nonrepeatable Read Phantoms Read uncommitted Yes Read committed (default) No Repeatable read Serializable Snapshot Discuss the effects that each of the transaction isolation levels has on data access. Be sure that students understand the READ COMMITTED isolation level, and that it is the default transaction isolation level. References: SET TRANSACTION ISOLATION LEVEL (Transact-SQL): Transaction Isolation Levels:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.