Designing for Performance General Database Optimizations Presentation Highlight: The Anatomy of a Data Modification Wednesday, 12 November 2003 – 16:30-18:00.

Slides:



Advertisements
Similar presentations
CM20145 Concurrency Control
Advertisements

1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 4: More on Locks Professor Chen Li.
Concurrency Control II. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Physical Design.
Transactions and Recovery Checkpointing Souhad Daraghma.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
Transaction Processing. Objectives After completing this lesson, you should be able to do the following: –Define transactions effectively for an application.
SQL Server Best Practices Keep Your Database In Top Performance Shape and Maintain Effective Backups September, 2007 Richard Kokoski.
1 Data Concurrency David Konopnicki 1997 Revised by Mordo Shalom 2004.
Module 15: Managing Transactions and Locks. Overview Introduction to Transactions and Locks Managing Transactions SQL Server Locking Managing Locks.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
1 - Oracle Server Architecture Overview
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
1 Transaction Management Database recovery Concurrency control.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Concurrency Control. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Transaction Processing.
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
Transactions and Recovery
Transaction log grows unexpectedly
Today’s Agenda Chapter 12 Admin Tasks Chapter 13 Automating Admin Tasks.
Transactions and Locks Lesson 22. Skills Matrix Transaction A transaction is a series of steps that perform a logical unit of work. Transactions must.
Building Highly Available Systems with SQL Server™ 2005 Vineet Gupta Evangelist – Data and Integration Microsoft Corp.
Managing Transaction and Lock Vu Tuyet Trinh Hanoi University of Technology 1.
Monday, 13 October 2003 The Anatomy of a Data Modification Subset of: What everyone should know about Performance, Recovery & Logging Monday, 13 October.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
7202ICT – Database Administration
1099 Why Use InterBase? Bill Todd The Database Group, Inc.
Lecture 12 Recoverability and failure. 2 Optimistic Techniques Based on assumption that conflict is rare and more efficient to let transactions proceed.
DB2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/DB01/003 Version No:2.0a Session Plan Introduction to Concurrency Control Different types.
© Dennis Shasha, Philippe Bonnet 2001 Log Tuning.
Concurrency Control in Database Operating Systems.
Understanding Logging & Recovery What Programmers Always Avoid Until it’s too Late! Kimberly L. Tripp Principal Mentor, Solid Quality Learning at
Module 11 Creating Highly Concurrent SQL Server® 2008 R2 Applications.
Transactions and Locks A Quick Reference and Summary BIT 275.
DBA 328 Designing for Performance: Optimization with Indexes Kimberly L. Tripp Solid Quality Learning – SolidQualityLearning.com
Connect with life Vinod Kumar Technology Evangelist - Microsoft
SQLintersection Understanding Transaction Isolation Levels Randy Knight Wednesday, 3:45-5:00.
Academic Year 2014 Spring. MODULE CC3005NI: Advanced Database Systems “DATABASE RECOVERY” (PART – 2) Academic Year 2014 Spring.
Chapter 15: Reliability and Security in Database Servers Neyha Amar CS 157B May 6, 2008.
Module 11: Managing Transactions and Locks
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
Module 14: Managing Transactions and Locks. Overview Introducing Transactions and Locks Managing Transactions Understanding SQL Server Locking Architecture.
Does the Optimistic Concurrency resolve your blocking problems Margarita Naumova, SQL Master Academy.
Delete Data Database Administration Fundamentals LESSON 3.4.
Locks, Blocks & Isolation Oh My!. About Me Keith Tate Data Professional for over 14 Years MCITP in both DBA and Dev tracks
No more waiting. Sponsors About me  Database Technology Specialist  MVP  Blogger  Author 3
Concurrency Control Managing Hierarchies of Database Elements (18.6)
Let Me Finish... Isolating Write Operations
Let Me Finish... Isolating Write Operations
The Vocabulary of Performance Tuning
On transactions, and Atomic Operations
Batches, Transactions, & Errors
Transactions, Locking and Query Optimisation
Turbo-Charged Transaction Logs
Chapter 10 Transaction Management and Concurrency Control
The PROCESS of Queries John Deardurff
The PROCESS of Queries John Deardurff Website: ThatAwesomeTrainer.com
Understanding Transaction Isolation Levels
On transactions, and Atomic Operations
The PROCESS of Queries John Deardurff
Let Me Finish... Isolating Write Operations
The Vocabulary of Performance Tuning
Let Me Finish... Isolating Write Operations
Transactions and Concurrency
A Beginners Guide to Transactions
Chapter 11 Managing Databases with SQL Server 2000
Isolation Levels Understanding Transaction Temper Tantrums
The Vocabulary of Performance Tuning
Presentation transcript:

Designing for Performance General Database Optimizations Presentation Highlight: The Anatomy of a Data Modification Wednesday, 12 November 2003 – 16:30-18:00 S207 Kimberly L. Tripp President, SYSolutions, Inc. – SQLSkills.com Principal Mentor, Solid Quality Learning – SolidQualityLearning.com

General Database Performance 12 November 2003  16:30-18:00 Speaker – Kimberly L. Tripp Independent Consultant/Trainer/Speaker/Writer Independent Consultant/Trainer/Speaker/Writer President, SYSolutions, Inc. President, SYSolutions, Inc. Principal Mentor, Solid Quality Learning Principal Mentor, Solid Quality Learning * In-depth, high quality training around the world! SQL Server MVP ( SQL Server MVP ( Microsoft Regional Director ( Microsoft Regional Director ( Writer/Editor for TSQL Solutions/SQL Magazine Writer/Editor for TSQL Solutions/SQL Magazine and Coauthor for MSPress title: SQL Server 2000 High Availability Coauthor for MSPress title: SQL Server 2000 High Availability Presenter/Technical Manager for SQL Server 2000 High Availability Overview DVD (MS Part# ) Presenter/Technical Manager for SQL Server 2000 High Availability Overview DVD (MS Part# )

General Database Performance 12 November 2003  16:30-18:00 The Anatomy of a Data Modification 1. User sends UPDATE Update is highly selective (only 5 rows) Update is highly selective (only 5 rows) Indexes exist to aid in finding these rows efficiently Indexes exist to aid in finding these rows efficiently The update is a SINGLE statement batch NOT enclosed in BEGIN TRAN…COMMIT TRAN block therefore this is IMPLICIT transaction The update is a SINGLE statement batch NOT enclosed in BEGIN TRAN…COMMIT TRAN block therefore this is IMPLICIT transaction 2. Server receives the request and locates the data in cache OR reads the data from disk into cache Since this is highly selective only the necessary pages are read into cache (maybe a few extra but that’s not important here) Since this is highly selective only the necessary pages are read into cache (maybe a few extra but that’s not important here) Let’s use an example where the 5 rows being modified are located on 3 different data pages Let’s use an example where the 5 rows being modified are located on 3 different data pages

General Database Performance 12 November 2003  16:30-18:00 What it looks like - Data UPDATE… Data Log Server… Cache

General Database Performance 12 November 2003  16:30-18:00 3. SQL Server proceeds to lock the necessary data Locks are necessary to give us a consistent point FOR ALL rows from which to start Locks are necessary to give us a consistent point FOR ALL rows from which to start If any other transaction(s) have ANY of these rows locked we will wait until ALL locks have been acquired before we can proceed. If any other transaction(s) have ANY of these rows locked we will wait until ALL locks have been acquired before we can proceed. In the case of this update (because it’s highly selective and because indexes exist to make this possible) SQL Server will use row level locking. In the case of this update (because it’s highly selective and because indexes exist to make this possible) SQL Server will use row level locking. The rows are locked but there are also “intent” locks at higher levels to make sure other larger locks (like page or table level locks) are not attempted (and fail) The rows are locked but there are also “intent” locks at higher levels to make sure other larger locks (like page or table level locks) are not attempted (and fail) There are a few locks that have already occurred – within indexes, etc. to read the data – but they are not significant here There are a few locks that have already occurred – within indexes, etc. to read the data – but they are not significant here The Anatomy of a Data Modification This sounds complex but it’s not too bad…

General Database Performance 12 November 2003  16:30-18:00 What it looks like - Locks Cache Page Row Update Lock

General Database Performance 12 November 2003  16:30-18:00 4. SQL Server can now begin to make the modifications – for EVERY row the process will include: 1. Change the lock to a stricter lock (eXclusive lock) An update lock helps to allow better concurrency by being compatible with other shared locks (readers). Readers can read the pre-modified data as it is transactionally consistent An update lock helps to allow better concurrency by being compatible with other shared locks (readers). Readers can read the pre-modified data as it is transactionally consistent The eXclusive lock is required to make the change because once modified no other reads should be able to see this un- committed change The eXclusive lock is required to make the change because once modified no other reads should be able to see this un- committed change 2. Make the modification to the data row (yes, in cache) 3. Log the modification to the transaction log pages (also in cache) The Anatomy of a Data Modification

General Database Performance 12 November 2003  16:30-18:00 What it looks like - Modifications Cache Page Row Update LockExclusive Lock x x Update LockExclusive Lock x x Update LockExclusive Lock x x Update LockExclusive Lock x x Update LockExclusive Lock x x L

General Database Performance 12 November 2003  16:30-18:00 5. Finally, the transaction is complete – this is the MOST critical step All rows have been modified All rows have been modified There are no other statements in this transaction – i.e. Implicit transaction There are no other statements in this transaction – i.e. Implicit transaction Steps are: Steps are: 1. Write all log pages to transaction log ON DISK 2. Release the locks 3. Send a message to the user: (5 Rows Affected) The Anatomy of a Data Modification

General Database Performance 12 November 2003  16:30-18:00 What it looks like Write-Ahead Logging L Data Log Server… Cache ~~~~~ ~~~~~ ~~~~~ ~~~~~ ~~~~~ ~~ Sequential writes Change … Log 5 Rows Affected After the log entries are made and the locks are released…

General Database Performance 12 November 2003  16:30-18:00 So now what? The transaction log ON DISK – is up to date The transaction log ON DISK – is up to date The data in CACHE – is up to date The data in CACHE – is up to date But when does the data get written from cache to disk? But when does the data get written from cache to disk?CHECKPOINT It’s important to realize that the sole purpose of checkpoint is NOT just to write committed pages… Instead a checkpoint writes ALL pages which have changed since they were brought into cache – regardless of the state of the transaction which changed them!

General Database Performance 12 November 2003  16:30-18:00 Transaction Recovery and Checkpoints Transactions… Action Required if restart recovery None CheckpointSystem Failure Roll forward Roll back Roll forward Roll back LD L/D L L Time

General Database Performance 12 November 2003  16:30-18:00 Check out for information about upcoming events, useful downloads and excellent scripts! There are quite a few resources and/or links to use. Check out for information about upcoming events, useful downloads and excellent scripts! There are quite a few resources and/or links to use. MSPress title: SQL Server 2000 High Availability Authors: Allan Hirt with Cathan Cook, Kimberly L. Tripp, Frank McBath ISBN: MSPress title: SQL Server 2000 High Availability Authors: Allan Hirt with Cathan Cook, Kimberly L. Tripp, Frank McBath ISBN: Check out the main page of for a sample chapter to download! Check out the main page of for a sample chapter to download! Resources

General Database Performance 12 November 2003  16:30-18:00 Resources From Books Online “Home Page” select White Papers to get to msdn From Books Online “Home Page” select White Papers to get to msdn For Tech Net articles use: hnol/sql/default.asp?frame=true For Tech Net articles use: hnol/sql/default.asp?frame=true See for all sorts of useful links, resources and whitepapers, etc. See for all sorts of useful links, resources and whitepapers, etc. Support Resources listed: ault.asp Support Resources listed: ault.asp ault.asp ault.asp

General Database Performance 12 November 2003  16:30-18:00 Whitepaper: Using Partitions in a Microsoft SQL Server 2000 Data Warehouse, onsindw.htm Whitepaper: Using Partitions in a Microsoft SQL Server 2000 Data Warehouse, onsindw.htm onsindw.htm onsindw.htm Whitepaper: Index Tuning Wizard for Microsoft SQL Server 2000, us/dnsql2k/html/itwforsql.asp?frame=true Whitepaper: Index Tuning Wizard for Microsoft SQL Server 2000, us/dnsql2k/html/itwforsql.asp?frame=true us/dnsql2k/html/itwforsql.asp?frame=true us/dnsql2k/html/itwforsql.asp?frame=true Support WebCast: SQL Server 2000 Profiler: What's New and How to Effectively Use It =%2Fservicedesks%2Fwebcasts%2Fwc %2Fwcblurb111400%2Easp Support WebCast: SQL Server 2000 Profiler: What's New and How to Effectively Use It =%2Fservicedesks%2Fwebcasts%2Fwc %2Fwcblurb111400%2Easp =%2Fservicedesks%2Fwebcasts%2Fwc %2Fwcblurb111400%2Easp =%2Fservicedesks%2Fwebcasts%2Fwc %2Fwcblurb111400%2EaspResources

General Database Performance 12 November 2003  16:30-18:00 Resources Improving Performance with SQL Server 2000 Indexed Views us/dnsql2k/html/indexedviews1.asp?frame=tr ue Improving Performance with SQL Server 2000 Indexed Views us/dnsql2k/html/indexedviews1.asp?frame=tr ue us/dnsql2k/html/indexedviews1.asp?frame=tr ue us/dnsql2k/html/indexedviews1.asp?frame=tr ue Microsoft SQL Server 2000 Index Defragmentation Best Practices ol/sql/maintain/Optimize/SS2KIDBP.asp?fram e=true Microsoft SQL Server 2000 Index Defragmentation Best Practices ol/sql/maintain/Optimize/SS2KIDBP.asp?fram e=true ol/sql/maintain/Optimize/SS2KIDBP.asp?fram e=true ol/sql/maintain/Optimize/SS2KIDBP.asp?fram e=true Support Resources listed: asp Support Resources listed: asp asp asp

General Database Performance 12 November 2003  16:30-18:00 Kimberly L. Tripp President, SYSolutions, Inc. Website: Principal Mentor, Solid Quality Learning Website: Please fill out your evaluation! Thank you!