Xiangyao Yu 9/23/2020
CS 764: Topics in Database Management Systems Lecture 6: Granularity of Locks
1
CS 764: Topics in Database Management Systems Lecture 6: Granularity - - PowerPoint PPT Presentation
CS 764: Topics in Database Management Systems Lecture 6: Granularity of Locks Xiangyao Yu 9/23/2020 1 Discussion Highlights SELECT JOB.title, count(*) |EMP| = 10000 tuples FROM JOB, EMP, DEPT |DEPT| = 100 tuples WHERE JOB.jid =
1
2
* assuming one-on-one mapping between jid and title
3
EMP DEPT
JOB
Group by EMP.jid and EMP.did EMP JOB
DEPT Group by EMP.jid and EMP.did Group by jid Group by title 1000 1 [1000x1] 10 10 [10x10] 1000 10 [1000x10] 1 [1000x1]
* assuming one-on-one mapping between jid and title
4
EMP DEPT
JOB
Group by EMP.jid and EMP.did EMP JOB
DEPT
Group by EMP.jid and EMP.did Group by jid Group by title 1000 100 [1000x100] 10 10 [10x10] 1000 10 [1000x10] 100 [1000x100]
* assuming one-on-one mapping between jid and title
5
6
7
8
9
10
11
12
13
14
15
DB | Areas | Files | Records
IS IS IS S
16
DB | Areas | Files | Records
IS IS IS S IX IX IX X
17
DB | Areas | Files | Records
IS IS IS S IX IX IX X IX IX SIX lock specific records in X mode
IS IX S SIX X IS Y Y Y Y N IX Y Y N N N S Y N Y N N SIX Y N N N N X N N N N N
18
IS IX S SIX X IS Y Y Y Y N IX Y Y N N N S Y N Y N N SIX Y N N N N X N N N N N
19
IS IX S SIX X IS Y Y Y Y N IX Y Y N N N S Y N Y N N SIX Y N N N N X N N N N N
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Locks Non- Recoverable Dirty Reads Non-repeatable
SQL Isolation level Dependenc y Degree 3 Long-X Long-R No No No Serializable W->W W->R R->W Degree 2 Long-X Short-R No No Yes Read committed W->W W->R Degree 1 Long-X No Yes Yes Read uncommitted W->W Degree 0 Short-X Yes Yes Yes None
40
Locks Non- Recoverable Dirty Reads Non-repeatable
SQL Isolation level Dependenc y Degree 3 Long-X Long-R No No No Serializable W->W W->R R->W Degree 2 Long-X Short-R No No Yes Read committed W->W W->R Degree 1 Long-X No Yes Yes Read uncommitted W->W Degree 0 Short-X Yes Yes Yes None
41
Locks Non- Recoverable Dirty Reads Non-repeatable
SQL Isolation level Dependenc y Degree 3 Long-X Long-R No No No Serializable W->W W->R R->W Degree 2 Long-X Short-R No No Yes Read committed W->W W->R Degree 1 Long-X No Yes Yes Read uncommitted W->W Degree 0 Short-X Yes Yes Yes None
42
Locks Non- Recoverable Dirty Reads Non-repeatable
SQL Isolation level Dependenc y Degree 3 Long-X Long-R No No No Serializable W->W W->R R->W Degree 2 Long-X Short-R No No Yes Read committed W->W W->R Degree 1 Long-X No Yes Yes Read uncommitted W->W Degree 0 Short-X Yes Yes Yes None
43
Locks Non- Recoverable Dirty Reads Non-repeatable
SQL Isolation level Dependenc y Degree 3 Long-X Long-R No No No Serializable W->W W->R R->W Degree 2 Long-X Short-R No No Yes Read committed W->W W->R Degree 1 Long-X No Yes Yes Read uncommitted W->W Degree 0 Short-X Yes Yes Yes None
44
Locks Non- Recoverable Dirty Reads Non-repeatable
SQL Isolation level Dependenc y Degree 3 Long-X Long-R No No No Serializable W->W W->R R->W Degree 2 Long-X Short-R No No Yes Read committed W->W W->R Degree 1 Long-X No Yes Yes Read uncommitted W->W Degree 0 Short-X Yes Yes Yes None
45
Locks Non- Recoverable Dirty Reads Non-repeatable
SQL Isolation level Dependenc y Degree 3 Long-X Long-R No No No Serializable W->W W->R R->W Degree 2 Long-X Short-R No No Yes Read committed W->W W->R Degree 1 Long-X No Yes Yes Read uncommitted W->W Degree 0 Short-X Yes Yes Yes None
46
Locks Non- Recoverable Dirty Reads Non-repeatable
Phantom SQL Isolation level Dependenc y Degree 3 Long-X Long-R No No No No Serializable W->W W->R R->W No No No Yes Repeatable reads Degree 2 Long-X Short-R No No Yes Yes Read committed W->W W->R Degree 1 Long-X No Yes Yes Yes Read uncommitted W->W Degree 0 Short-X Yes Yes Yes Yes None
47
48
49
50