14-PhysicalAccess
14-PhysicalAccess
DB
MG
1
DBMS Architecture
SQL INSTRUCTION
OPTIMIZER
CONCURRENCY CONTROL
MANAGEMENT OF ACCESS
METHODS
Index Files
System DATABASE
Catalog
Data Files
2
DB
MG
Physical Access Structures
3
DB
MG
Access Method Manager
4
DB
MG
Access method
5
DB
MG
Organization of a disk page
6
DB
MG
Remarks
7
DB
MG
Database Management Systems
DB
MG
8
Physical Access Structures
10
DB
MG
Heap file
11
DB
MG
Ordered sequential structures
12
DB
MG
Ordered sequential structures
Problem
preserving the sort order when inserting new
tuples
it may also hold for update
Solution
Leaving a percentage of free space in each block
during table creation
On insertion, dynamic (re)sorting in main memory of
tuples into a block
Alternative solution
Overflow file containing tuples which do not fit into
the correct block
13
DB
MG
Ordered sequential structures
14
DB
MG
Tree structures
15
DB
MG
General characteristics
16
DB
MG
Tree structure
U1
17
DB
MG
General characteristics
18
DB
MG
Tree structure
U1
19
DB
MG
General characteristics
20
DB
MG
Tree structure
U1
DATA
21
DB
MG
B-Tree and B+-Tree
22
DB
MG
B-Tree structure
U1
DATA
23
DB
MG
B+-Tree structure
U1
DATA
24
DB
MG
B-Tree and B+-Tree
26
DB
MG
Clustered B+-Tree index
U1
27
DB
MG
Unclustered
28
DB
MG
Unclustered B+-Tree index
U1
Data
29
DB
MG
Example: Unclustered B+-Tree index
STUDENT (StudentId, Name, Grade)
12 78 Grade > 78
Grade < 12
12 <= Grade <= 78
19 56
12<=Grade < 19 56< Grade <=78
33 44
19 <= Grade < 33 44< Grade <= 56
33 <= Grade <= 44
LEAF
19 22 30 30 33 34 34 34 40 50
(T1) (T2 ) (T3) (T4) (T5) (T6 ) (T10) (T7) (T8) (T9)
T1 T6 T10 T2 T3 T5 T4 T7 T8 T9
19 34 34 22 30 33 30 34 40 50
DB
30
MG DATA FILE FOR STUDENT TABLE
Example: Clustered B+-Tree index
STUDENT (StudentId, Name, Grade)
12 78 Grade > 78
Grade < 12
12 <= Grade <= 78
19 56
12<=Grade < 19 56< Grade <=78
33 44
19 <= Grade < 33 44< Grade <= 56
33 <= Grade <= 44
LEAF
T1 T2 T3 T4 T5 T6 T10 T7 T8 T9
19 22 30 30 33 34 34 34 40 50
DB
31
MG
Advantages and disadvantages
Advantages
Very efficient for range queries
Appropriate for sequential scan in the order of the
key field
Always for clustered, not guaranteed otherwise
Disadvantages
Insertions may require a split of a leaf
possibly, also of intermediate nodes
computationally intensive
Deletions may require merging uncrowded
nodes and re-balancing
32
DB
MG
Hash structure
33
DB
MG
Example: hash index
STUDENT (StudentId, Name, Grade)
BLOCK 0
34
DB
MG
Hash index
Advantages
Very efficient for queries with equality predicate on
the key
No sorting of disk blocks is required
Disadvantages
Inefficient for range queries
Collisions may occur
35
DB
MG
Unclustered hash index
36
DB
MG
Example: Unclustered hash index
STUDENT (StudentId, Name, Grade)
BLOCK 0
TUPLE T1 T1 30
GRADE = 30 H(GRADE=30)=1
30 → T1
BLOCK 1 40 → T2
TUPLE T2 T2 40
GRADE = 40 H(GRADE=40)=1
BLOCK 2
DATA FILE FOR
STUDENT TABLE
INDEX BLOCKS
37
DB
MG
Bitmap index
38
DB
MG
Bitmap index
39
DB
MG
Example: Bitmap index
EMPLOYEE (EmployeeId, Name, Job)
DATA FILE
FOR EMPLOYEE
TABLE
40
DB
MG
Bitmap index
Advantages
Very efficient for boolean expressions of predicates
Reduced to bit operations on bitmaps
Appropriate for attributes with limited domain
cardinality
Disadvantages
Not used for continuous attributes
Required space grows significantly with domain
cardinality
41
DB
MG