Prob.1 CSE 255 Query Optimization Problem  CustomerName (  BranchName=‘Storrs’^ Balance > 1000 ( Branch x Account x Depositor))  Consider the Three.

Slides:



Advertisements
Similar presentations
Cs4432concurrency control1 CS4432: Database Systems II Lecture #21 Concurrency Control : Theory Professor Elke A. Rundensteiner.
Advertisements

CS 277: Database System Implementation Notes 11: View Serializability
More About Transaction Management Chapter 10. Contents Transactions that Read Uncommitted Data View Serializability Resolving Deadlocks Distributed Databases.
Unit 9 Concurrency Control. 9-2 Wei-Pang Yang, Information Management, NDHU Content  9.1 Introduction  9.2 Locking Technique  9.3 Optimistic Concurrency.
1 Concurrency Control Chapter Conflict Serializable Schedules  Two actions are in conflict if  they operate on the same DB item,  they belong.
1 Lecture 11: Transactions: Concurrency. 2 Overview Transactions Concurrency Control Locking Transactions in SQL.
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Database System Principles 18.7 Tree Locking Protocol CS257 Section 1 Spring 2012 Dhruv Jalota ID: 115.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #22 Concurrency Control Professor Elke A. Rundensteiner.
Concurrency Control II
Cs4432concurrency control1 CS4432: Database Systems II Lecture #23 Concurrency Control Professor Elke A. Rundensteiner.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #22 Concurrency Control: Locking-based Protocols Professor Elke A. Rundensteiner.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Concurrency Control Chapter 17 Sections
Kyoung-Hwan Yun (#110). Conflicts Precedence Graphs and a Test for Conflict- Serializability.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 7: View-Serializable Schedules Professor Chen Li.
Concurrent Transactions Even when there is no “failure,” several transactions can interact to turn a consistent state into an inconsistent state.
Conflict-Serializability Bharath Kumar Manur Venkataramana Class ID No:- 110.
Concurrent Transactions Even when there is no “failure,” several transactions can interact to turn a consistent state into an inconsistent state.
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
Concurrency III (Timestamps). Schedulers A scheduler takes requests from transactions for reads and writes, and decides if it is “OK” to allow them to.
Winter 2002Arthur Keller – CS 18013–1 Schedule Today: Feb. 21 (TH) u Transactions, Authorization. u Read Sections Project Part 5 due. Feb. 26.
Concurrency. Busy, busy, busy... In production environments, it is unlikely that we can limit our system to just one user at a time. – Consequently, it.
Transaction Processing: Concurrency and Serializability 10/4/05.
Transaction Management
Fall 2001Arthur Keller – CS 18012–1 Schedule Nov. 6 (T) Transactions, Authorization. u Read Sections Nov. 8 (TH) Object-Oriented Database Design.
Concurrency. Correctness Principle A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction,
Query Optimization. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Physical Design.
©Silberschatz, Korth and Sudarshan14.1Database System Concepts 3 rd Edition Chapter 14: Query Optimization Overview Catalog Information for Cost Estimation.
1 Concurrency Control. 2 Transactions A transaction is a list of actions. The actions are reads (written R T (O)) and writes (written W T (O)) of database.
Cs4432concurrency control1 CS4432: Database Systems II Concurrency Control.
© 1997 UW CSE 11/13/97N-1 Concurrency Control Chapter 18.1, 18.2, 18.5, 18.7.
Relational Model: Examples. Banking Example branch (branch_name, branch_city, assets) customer (customer_name, customer_street, customer_city) account.
10.4 How to Find a Perfect Matching We have a condition for the existence of a perfect matching in a graph that is necessary and sufficient. Does this.
TRANSACTIONS. Objectives Transaction Concept Transaction State Concurrent Executions Serializability Recoverability Implementation of Isolation Transaction.
Exact methods for ALB ALB problem can be considered as a shortest path problem The complete graph need not be developed since one can stop as soon as in.
Distributed DBMSPage © 1998 M. Tamer Özsu & Patrick Valduriez Outline Introduction Background Distributed DBMS Architecture Distributed Database.
Winter 2006Keller, Ullman, Cushing13–1 TRANSACTION MANAGEMENT Airline Reservationsmany updates Statistical Abstract of the USmany queries Atomicity – all.
Concurrency Server accesses data on behalf of client – series of operations is a transaction – transactions are atomic Several clients may invoke transactions.
Computing & Information Sciences Kansas State University Tuesday, 03 Apr 2007CIS 560: Database System Concepts Lecture 29 of 42 Tuesday, 03 April 2007.
Chapter 14 Transactions Yonsei University 1 st Semester, 2015 Sanghyun Park.
1 CS542 Concurrency Control: Theory and Protocol Professor Elke A. Rundensteiner.
1 Concurrency Control Lecture 22 Ramakrishnan - Chapter 19.
Relational Algebra HW2 Turn in as a hardcopy at the start of next class period. You may work this assignment in groups.
Nested Subqueries in SQL By Kenneth Cheung CS 157A Section 2 Professor Lee.
Lecture 9- Concurrency Control (continued) Advanced Databases Masood Niazi Torshiz Islamic Azad University- Mashhad Branch
1 Controlled concurrency Now we start looking at what kind of concurrency we should allow We first look at uncontrolled concurrency and see what happens.
1 Chapter 22: Elementary Graph Algorithms III. 2 About this lecture Topological Sort.
Jinze Liu. ACID Atomicity: TX’s are either completely done or not done at all Consistency: TX’s should leave the database in a consistent state Isolation:
Query Languages Language in which user requests information from the database. Categories of languages Procedural Non-procedural, or declarative “Pure”
Query Processing and Query Optimization Database System Implementation CSE 507 Slides adapted from Silberschatz, Korth and Sudarshan Database System Concepts.
Database System Implementation CSE 507
Concurrency Control Techniques
Schedule Today Transactions, Authorization. Sections
Transaction Management
Topological Sort (topological order)
Temple University – CIS Dept. CIS661 – Principles of Data Management
Outline Introduction Background Distributed DBMS Architecture
Algorithm 2 Algorithm 2 Problem
Transaction Management
Concurrency Control Chapter 17
What to do when you don’t know anything know nothing
Conflicts.
Concurrency Control Chapter 17
Transaction Management
CPSC-608 Database Systems
CSE 417: Algorithms and Computational Complexity
C. Faloutsos Transactions
Temple University – CIS Dept. CIS616– Principles of Data Management
Richard Anderson Lecture 5 Graph Theory
Chapter 22: Elementary Graph Algorithms III
Presentation transcript:

prob.1 CSE 255 Query Optimization Problem  CustomerName (  BranchName=‘Storrs’^ Balance > 1000 ( Branch x Account x Depositor))  Consider the Three Relations: Branch (BranchName, BranchCity, Assets) Account(AccountNumber, BranchName, Balance) Depositor(CustomerName, AccountNumber)  Optimize the following Relational Express by  Drawing the Initial Expression Tree  Optimizing (Rewriting) the Tree  The Query Finds all Customers who have Accounts at the Storrs Branch with Balance > 1000

prob.2 CSE 255 Depositor BranchAccount   CustomerName BranchName = Storrs ^ Balance > 1000 X X Create the Initial Query Tree

prob.3 CSE 255 Algorithm 2  Algorithm 2 Problem  Apply Algorithm 2 to the Schedule of Transactions on the next Slide  In this Case, Wlock Implies Reading  For this Problem:  Draw the Precedence Graph  Check to See if the Schedule is Serializable  If So, Determine ALL Serial Schedules

prob.4 CSE 255 Algorithm 2: Read/Write Lock Model  Input: Schedule S for Transactions T 1, T 2, … T k  Output: Is S Serializable? If so, Serial Schedule  Method: Create a Directed Precedence Graph G:  Suppose in S, T i :Rlock A. If T j : Wlock A is the Next Transaction to Wlock A (if it exists) then place an Arc from T i to T j. Repeat for all T i ’s. Note for all Rlocks before the Wlock on A!  Suppose in S, T i :Wlock A. If T j : Wlock A is the Next Transaction to Wlock A (if it exists) then place an Arc from T i to T j. Further, if there exists T m :Rlock A after T i :Wlock A but before T j : Wlock A, then Draw an Arc from T i to T m.  Review the Resulting Precedence Graph  If G has Cycles - Non-Serializable  If G is Acyclic - Topological Sort for Serial Schedule

prob.5 CSE 255 Apply Algorithm 2 to Following Schedule T 1 T 2 T 3 T 4 (1) Rlock A (2)Rlock A (3)Wlock C (4) Unlock C (5)Rlock C (6) Wlock B (7)Unlock B (8)Rlock B (9)Unlock A (10)Unlock A (11)Wlock A (12)Rlock C (13)Wlock D (14)Unlock B (15)Unlock C (16)Rlock B (17)Unlock A (18)Wlock A (19)Unlock B (20)Wlock B (21)Unlock B (22)Unlock D (23)Unlock C (24)Unlock A

prob.6 CSE 255 Algorithm 3  Input: Schedule S for Transactions T 1, T 2, … T k  Output: Is S Serializable? If so, Serial Schedule  Method: Create a Directed Polygraph Graph P:  1. Augment S with Dummy T o (Write Every Item) an Dummy T f (Read Every Item)  2. Create Initial Polygraph P by Adding Nodes for T o, T f, and Each T i Transaction, in S  3. Place an Arc from T i to T j Whenever T j Reads A in Augmented S (with Dummy States) that was Last Written by T i. Repeat this Step for all Arcs. Don’t Forget to Consider Dummy States!  4. Discover Useless Transactions - T is Useless if there is no Path from T to T f  This is the “Initialization” Phase of Algorithm 3

prob.7 CSE 255 Algorithm 3  Method: Reassess the Initial Polygraph P:  5. For Each Remaining Arc T i to T j (meaning that T j Reads Item A Written by T i ), Consider all other T  T o and T  T f that Also Writes A:  If T i = T o and T j = T f then Add No Arcs  If T i = T o and T j  T f then Add Arc from T j to T  If T i  T o and T j = T f then Add Arc from T to T i  If T i  T o and T j  T f then Add Arc Pair from T to T i and T j to T  6. Determine if P is Acyclic by “Choosing” One Transaction Arc for Each Pair - Make Choices Carefully  7. If Acyclic - Serializable - Perform Topological Sort without T o, T f for Equivalent Serial Schedule. Else - Not Serializable

prob.8 CSE 255 Apply Algorithm 3 to Following Schedule T 1 T 2 T 3 T 4 (T 0 ) Write A, B (1) Wlock A (2)Rlock B (3)Unlock A (4) Rlock A (5)Unlock B (6) Wlock B (7)Rlock A (8)Unlock B (9)Wlock B (10)Unlock A (11)Unlock A (12)Wlock A (13)Unlock B (14)Rlock B (15)Unlock A (16)Unlock B (T F ) Read A, B

prob.9 CSE 255 Algorithm 4: Optimistic CC  Let T be a Transaction with Timestamp t Attempting to Perform Operation X on a Data Item I with Readtime t R and Writetime t W  If (X = Read and t  t W ) or (X = Write and t  t R ) then Perform Operation  If t > t R then set t R = t for Data Item I  If t > t W then set t W = t for Data Item I  If (X = Write and t R  t < t W ) the Do Nothing since Later Write will Cancel out the Write of T  If (X = Read and t < t W ) or (X = Write and t < t R ) then Abort the Operation  1st - T trying to Read Item Before it was Written  2nd - T trying to Write an Item Before it was Read

prob.10 CSE 255 Algorithm 4  Algorithm 4 Problem  Apply Algorithm 4 to the Schedule of Transactions on the next Slide  Assume the Following Transaction Times  T 1 = 175, T 2 = 150, T 3 = 200, T 4 = 225  Determine the RT and WT for A, B, C, and D at each Step  Indicate when a Transaction Aborts or has No Effect  Remember, RT=WT=0 for A, B, C, and D Prior to the 1st Step in the Schedule

prob.11 CSE 255 T 1 =175T 2 =150 T 3 =200 T 4 =225 A B C D (1) Read A (2)Read A (3)Write C (4) Read C (5) Write B (6) Read B (7) Write A (8) Read C (9)Write D (10)Read B (11) Write A (12) Write B Algorithm 4 Problem Initially RT/WT of A, B, C, and D are all Zero (0)