Indexing: Practice Exercises
Indexing: Practice Exercises
14
Indexing
Practice Exercises
14.1 Indices speed query processing, but it is usually a bad idea to create indices on
every attribute, and every combination of attributes, that are potential search
keys. Explain why.
14.2 Is it possible in general to have two clustering indices on the same relation for
different search keys? Explain your answer.
14.3 Construct a B+ -tree for the following set of key values:
Assume that the tree is initially empty and values are added in ascending order.
Construct B+ -trees for the cases where the number of pointers that will fit in
one node is as follows:
a. Four
b. Six
c. Eight
14.4 For each B+ -tree of Exercise 14.3, show the form of the tree after each of the
following series of operations:
a. Insert 9.
b. Insert 10.
c. Insert 8.
d. Delete 23.
47
48 Chapter 14 Indexing
e. Delete 19.
14.5 Consider the modified redistribution scheme for B+ -trees described on page
651. What is the expected height of the tree as a function of n?
14.6 Give pseudocode for a B+ -tree function findRangeIterator(), which is like the
function findRange(), except that it returns an iterator object, as described
in Section 14.3.2. Also give pseudocode for the iterator class, including the
variables in the iterator object, and the next() method.
14.7 What would the occupancy of each leaf node of a B+ -tree be if index entries
were inserted in sorted order? Explain why.
14.8 Suppose you have a relation r with nr tuples on which a secondary B+ -tree is
to be constructed.
a. Give a formula for the cost of building the B+ -tree index by inserting one
record at a time. Assume each block will hold an average of f entries and
that all levels of the tree above the leaf are in memory.
b. Assuming a random disk access takes 10 milliseconds, what is the cost
of index construction on a relation with 10 million records?
c. Write pseudocode for bottom-up construction of a B+ -tree, which was
outlined in Section 14.4.4. You can assume that a function to efficiently
sort a large file is available.
14.9 The leaf nodes of a B+ -tree file organization may lose sequentiality after a se-
quence of inserts.