How to measure performance of database operations
Performance of an order index: example
Information:
1000 data records in a data file
Index file contains
1000 search keys (+ pointers) (to the
1000 data records)
Each index block contains
10 search keys (+ pointers)
There are 100 (index) blocks) in
the (ordered) index file
Performance of an order index: example
Question:
Given a
search key for
a data record...
How many
index blocks do you need to
access (= read)
(in the worst case) to
find the
database address
of that data record
(in the index file)
Performance of an order index: example
Answer:
Use binary search
in the index file
to find the index block
that contains the given search key
Review: multi-level index files
Example multi-level index
Consider the
original index file:
Example multi-level index
We can add an
(primary) index file on the
(ordered) index file:
Example multi-level index
Since the 2nd level index is still
large,
we can add an
(primary) index file on the
2nd index file:
Performance of a multi-level index file
Answer: 3 disk IO operations
We can use the
top level index to
find
the
index block in the 2nd level index
that will (guaranteed)
contain the
search key:
Answer: 3 disk IO operations
Then,
we use
2nd level index
to find
the index block in the final level index
that will (guaranteed)
contain
the search key:
Answer: 3 disk IO operations
Finally,
we access the
(orignal) index file block
and find
the database address
for the record:
How many level of indexes do you need ???
❮
❯