













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














Today– Single level index review– Multilevel index
-^
Reading assignment:– Chapter 5 and Sections 6.0-6.
I am in the process of grading it
-^
Harshness of auto grading– Does not compile
Æ
grade = 0
We will have some way to replace lowestprogram
-^
Please follow instructions exactly for turning insubsequent assignment
Index contains one index entry / block– Example index entry for a primary index on student #
Time to access in I/O operations– Without index: log
B 2
2
B
idx
The student # of the first record on block 937 is 4137
The number ofblocks in the file
The number ofblocks in index
Index contains one entry / unique value ofindexing field– Example index entry for clustered index on major
Time to access in I/O operations– Without index: log
B 2
2
B
idx
The first block with a record whose major is CompSci has blkID=
The number ofblocks in the file
The number ofblocks in index
Setting
file w/ 30,000 fixed length records of 100
bytes on 1024 byte blocks– Records / block = 10– # blocks in file = 3,000– Search for key w/o idx: log2 3000 = about 12
-^
Make index on 9 byte ordering key, block ID is 6bytes– 68 index entries / block, 3,000 total index entries– 45 blocks in the index– Search for key w/ index = 1+log2 45 = 7 I/Os
Now search for non-ordering key:– Average is 1500 block reads
-^
Construct secondary key on 9 byte non orderingkey field:– Index entry still 15 bytes, 68 entries / block– But we need entry for each of the 30,000 records
the record is 10.
Consider a clustered index on a non-key field
-^
The index itself is an ordered file of(value, blockPtr) pairs where value is a key field
-^
We can thus construct a primary index on“value”
-^
Add levels until the index fits in one block
In general, inserts and deletes to the filerequires updating the index
-^
Each level of the index is a physically orderedfile thus updates are expensive
-^
One solution: leave some space on each indexfor inserting new index entries
B+ trees
B+ trees are the most popular implementation ofdynamic multilevel indexes
-^
There are two types B+ tree index blocks–
Internal nodes:
contain index field values (used to
guide the search) and pointers blocks in lower levelsof the B+ tree (tree pointers)
Leaf nodes:
contain values and matching RIDs
A B+ tree is always balanced (ie, distance fromthe root to leaf is the same for each leaf)
-^
Let
p
be the maximum number of tree pointers
on an internal block– Other than root, each internal page has at least
ceil(p/2) tree pointers
q
tree pointers has
q-
search field
values
Key aspect of B+ trees are graceful algorithmsfor handling insertions and delete