You are on page 1of 14

Indexes

Types of indexes in a data


warehousing environment

• Bitmap Indexes
• B-Tree Indexes
• Index Compression
• Local Indexes and Global Indexes
Bitmap Indexes
• Bitmap indexing provides:
– Reduced response time for large
classes of ad hoc queries.
– Reduced storage requirements
compared to other indexing techniques.
– Dramatic performance gains even on
hardware with a relatively small number
of CPUs or a small amount of memory.
– Efficient maintenance during parallel
DML and loads.
Bitmap Indexes
• A regular index stores a list of row-ids for each key
corresponding to the rows with that key value.
• In a bitmap index, a bitmap for each key value
replaces a list of row-ids.
• Each bit in the bitmap corresponds to a possible
row-id, and if the bit is set, it means that the row
with the corresponding row-id contains the key
value.
• A mapping function converts the bit position to an
actual row-id, so that the bitmap index provides
the same functionality as a regular index.
Bitmap Indexes
• Bitmap indexes store the bitmaps in a
compressed way.
• Bitmap indexes are most effective for
queries that contain multiple conditions in
the WHERE clause.
• Rows that satisfy some, but not all,
conditions are filtered out before the table
itself is accessed.
• This improves response time, often
dramatically.
Cardinality
• The advantages of using bitmap indexes are greatest for
columns in which the ratio of the number of distinct values
to the number of rows in the table is small. We refer to this
ratio as the degree of cardinality.
Example: A gender column, which has only two distinct
values (male and female), is optimal for a bitmap index.
• Data warehouse administrators also build bitmap indexes
on columns with higher cardinalities.
Example: On a table with one million rows, a column with
10,000 distinct values is a candidate for a bitmap index. A
bitmap index on this column can outperform a B-tree index,
particularly when this column is often queried in conjunction
with other indexed columns.
• In a typical data warehouse environments, a bitmap index
can be considered for any non-unique column.
B-trees and Bitmap
indexes
• B-tree indexes are most effective for high-cardinality
data.
• B-tree indexes should be used only for unique columns or
other columns with very high cardinalities (that is,
columns that are almost unique).
• The majority of indexes in a data warehouse should be
bitmap indexes.
• In ad hoc queries and similar situations, bitmap indexes
can dramatically improve query performance.
• AND and OR conditions in the WHERE clause of a query
can be resolved quickly.
• If the resulting number of rows is small, the query can be
answered quickly without resorting to a full table scan.
Example:

• cust_gender, cust_marital_status, and cust_income_level are all low-


cardinality columns (3 values for marital status and region, 2 values
for gender, and 12 for income level)
• bitmap indexes are ideal for these columns.
• Do not create a bitmap index on cust_id because this is a unique
column. Instead, a unique B-tree index on this column provides the
most efficient representation and retrieval.
• The bitmap index for the cust_gender
is
• For a query:
• Select Count(*) From customers
• Where marital-status=“Married” and
(region=“central” or region=“west”)
Bitmap Indexes and
Nulls
• Bitmap indexes include rows that have
NULL
• values.
• Indexing of nulls can be useful for some
types of SQL statements, such as queries
with the aggregate function COUNT.
Select Count(*) From customers
Where marital-status IS NULL;
• This query would not be able to use a B-
tree index, because B-tree indexes do not
store the NULL values.
Using Bitmap Join
Indexes
• A bitmap join index for the join of two or more tables.
• In a bitmap join index, the bitmap for the table to be
indexed is built for values coming from the joined
tables.
• In a data warehousing environment, the join
condition is an equi-inner join between the primary
key column or columns of the dimension tables and
the foreign key column or columns in the fact table.
• A bitmap join index can improve the performance by
an order of magnitude.
• By storing the result of a join, the join can be avoided
completely for SQL statements using a bitmap join
index.
Bitmap Join Index
Restrictions and
Requirements
Only one table can be updated concurrently by

different transactions when using the bitmap join
index.
• The columns in the index must all be columns of the
dimension tables.
• The dimension table column(s) participating the join
with the fact table must be either the primary key
column(s) or with the unique constraint.
• If a dimension table has composite primary key,
each column in the primary key must be part of the
join.
Using B-Tree Indexes
• In a B-tree index, the bottom level of the
index holds the actual data values and
pointers to the corresponding rows,
• In general, use B-tree indexes when you
know that your typical query refers to the
indexed column and retrieves a few rows.
• In these queries, it is faster to find the rows
by looking at the index.
• B-tree indexes are most commonly used in
a data warehouse to index unique or near-
unique keys

You might also like