Presentation is loading. Please wait.

Presentation is loading. Please wait.

Batches, Transactions, & Errors

Similar presentations


Presentation on theme: "Batches, Transactions, & Errors"— Presentation transcript:

1 Batches, Transactions, & Errors
John Deardurff Website: January 16, 2016

2 Presentation Topics Batches vs Transactions Types of Errors
Working with Batches ACID Transactions Explicit Transactions Locks Transaction Isolation Levels

3 VS Batches vs. Transactions Batches Transactions TSQL2012.mdf
Sends Code to the Processor Sends Data to the Database

4 The Process of Queries Parse Resolve Optimize Compile Execute Execute
Ad Hoc Query Stored Procedure Syntax Parse Execution Context Resolve Compile Optimize Execution Plan Procedure Cache Compile Run Time Execute Execute SQL Sets

5 Working with Batches

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 Auto Commit Transactions without Error Handling
TSQL2012.ldf Checkpoint TSQL2012.mdf

9 Explicit Transactions without Error Handling
TSQL2012.ldf Checkpoint TSQL2012.mdf

10 Explicit Transactions with Error Handling
TSQL2012.ldf TSQL2012.mdf Checkpoint

11 Transaction Recovery Transaction Recovery Action Required 1 None 2
Roll forward 3 Roll back 4 Roll forward 5 Roll back Checkpoint System Failure

12 What are Locks? Transaction 1 Transaction 2 TSQL2012.mdf

13 Module 13: Creating Highly Concurrent SQL Server 2012 Applications
Course 10776A Module 13: Creating Highly Concurrent SQL Server 2012 Applications What Problems does Locking Prevent? 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

15 Uncommitted dependency (dirty read)
Clean Read Dirty Read

16 Inconsistent analysis (non-repeatable read)
READ COMMITTED REPEATABLE READ

17 Phantom Reads – (Add Records for Demo)

18 Phantom Reads Missing records

19 Transaction Isolation Levels

20 Module 13: Creating Highly Concurrent SQL Server 2012 Applications
Course 10776A Module 13: Creating Highly Concurrent SQL Server 2012 Applications Transaction Isolation Levels 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:


Download ppt "Batches, Transactions, & Errors"

Similar presentations


Ads by Google