20.2 An Overview of Database Tuning in Relational Systems 735
index is dropped or created; this loss of service must be accounted for. Besides drop-
ping or creating indexes and changing from a nonclustered to a clustered index and
vice versa, rebuilding the index may improve performance. Most RDBMSs use
B
+
-trees for an index. If there are many deletions on the index key, index pages may
contain wasted space, which can be claimed during a rebuild operation. Similarly,
too many insertions may cause overflows in a clustered index that affect perfor-
mance. Rebuilding a clustered index amounts to reorganizing the entire table
ordered on that key.
The available options for indexing and the way they are defined, created, and reor-
ganized varies from system to system. As an illustration, consider the sparse and
dense indexes in Chapter 18. A sparse index such as a primary index (see Section
18.1) will have one index pointer for each page (disk block) in the data file; a dense
index such as a unique secondary index will have an index pointer for each record.
Sybase provides clustering indexes as sparse indexes in the form of B
+
-trees, whereas
INGRES provides sparse clustering indexes as ISAM files and dense clustering
indexes as B
+
-trees. In some versions of Oracle and DB2, the option of setting up a
clustering index is limited to a dense index (with many more index entries), and the
DBA has to work with this limitation.
20.2.2 Tuning the Database Design
In Section 20.1.2, we discussed the need for a possible denormalization, which is a
departure from keeping all tables as BCNF relations. If a given physical database
design does not meet the expected objectives, the DBA may revert to the logical
database design, make adjustments such as denormalizations to the logical schema,
and remap it to a new set of physical tables and indexes.
As discussed, the entire database design has to be driven by the processing require-
ments as much as by data requirements. If the processing requirements are dynam-
ically changing, the design needs to respond by making changes to the conceptual
schema if necessary and to reflect those changes into the logical schema and physi-
cal design. These changes may be of the following nature:
■
Existing tables may be joined (denormalized) because certain attributes
from two or more tables are frequently needed together: This reduces the
normalization level from BCNF to 3NF, 2NF, or 1NF.
5
■
For the given set of tables, there may be alternative design choices, all of
which achieve 3NF or BCNF. We illustrated alternative equivalent designs in
Chapter 16. One normalized design may be replaced by another.
■
A relation of the form R(K,A, B, C, D, ...)—with K as a set of key attributes—
that is in BCNF can be stored in multiple tables that are also in BCNF—for
example,
R1(K, A, B), R2(K, C, D, ), R3(K, ...)—by replicating the key K in each
table. Such a process is known as vertical partitioning. Each table groups
5
Note that 3NF and 2NF address different types of problem dependencies that are independent of
each other; hence, the normalization (or denormalization) order between them is arbitrary.