You are on page 1of 5

Bitmap index

From Wikipedia, the free encyclopedia


Jump to: navigation, search

A bitmap index is a special kind of database index that uses bitmaps.

Bitmap indexes have traditionally been considered to


work well for data such as gender, which has a small
number of distinct values, for example male and
female, but many occurrences of those values. This
would happen if, for example, you had gender data
for each resident in a city. Bitmap indexes have a
significant space and performance advantage over
other structures for such data. However, some
researchers argue that Bitmap indexes are also useful
for unique valued data which is not updated
frequently.[1] Bitmap indexes use bit arrays
(commonly called bitmaps) and answer queries by
performing bitwise logical operations on these
bitmaps.
Bitmap indexes are also useful in the data
warehousing applications for joining a large fact table
to smaller dimension tables[2] such as those arranged
in a star schema. In other scenarios, a B-tree index
would be more appropriate.

[edit] Example
Continuing the gender example, a bitmap index may be logically viewed as follows:
Bitmaps
Identifier Gender
F M
1 Female 1 0
2 Male 0 1
3 Male 0 1
4 Unspecified 0 0
5 Female 1 0

On the left, identifier refers to the unique number


assigned to each customer, gender is the data to be
indexed, the content of the bitmap index is shown as
two columns under the heading bitmaps. Each
column in the above illustration is a bitmap in the
bitmap index. In this case, there are two such
bitmaps, one for gender Female and one for gender
Male. It is easy to see that each bit in bitmap M
shows whether a particular row refers to a male. This
is the simplest form of bitmap index. Most columns
will have more distinct values. For example, the sales
amount is likely to have a much larger number of
distinct values. Variations on the bitmap index can
effectively index this data as well. We briefly review
three such variations.
Note: many of the references cited here are reviewed
at.[3] For those who might be interested in
experimenting with some of the ideas mentioned
here, many of them are implemented in open source
software such as FastBit, the Lemur Bitmap Index C+
+ Library, and LucidDB.
Bitmap Index – when to use it?
Posted by Dylan Wan on February 1, 2008

I will cover how Bitmap index work, when to use it and how to use it in this article.

How does it work?

The bitmap index stores the column values in bits. Each bit represents a single value. For
example, the gender column has two possible values: Male and Female. three bit will be
used in the bitmap to capture the index on the gender column. A good example can be
seen in reference 1. So the more distinct value is, the more space is required to store the
bitmap.

Internally, the database engine, like Oracle, uses a map function to converts the bit
location to the distinct value. (See reference #2) Many bitmap indexes can be used
together since database can merge it, so this can improve the response time. (See
Reference #3 for the example of merging the index on Marital Status and Region)

When to use it?

1. Low cardinality – Some dabase vendor, like Oracle, provides very practical
suggestion -(See Reference #3 and 4)

• If the number of distinct values of a column is less than 1% of the number of rows
in the table, or if the values in a column are repeated more than 100 times, then
the column is a candidate for a bitmap index.
• B-tree indexes are most effective for high-cardinality data: that is, data with
many possible values, such as CUSTOMER_NAME or PHONE_NUMBER.
• There are 100 or more rows for each distinct value in the indexed column. When
this limit is met, the bitmap index will be much smaller than a regular index, and
you will be able to create the index much faster than a regular index.

2. No or little insert/update -

Updating bitmap indexes take a lot of resources. Here are the suggestions: (See Reference
5)

• Building and maintaining an index structure can be expensive, and it can


consume resources such as disk space, CPU, and I/O capacity. Designers must
ensure that the benefits of any index outweigh the negatives of index
maintenance.
• Use this simple estimation guide for the cost of index maintenance: each index
maintained by an INSERT, DELETE, or UPDATE of the indexed keys requires about
three times as much resource as the actual DML operation on the table. What this
means is that if you INSERT into a table with three indexes, then it will be
approximately 10 times slower than an INSERT into a table with no indexes. For
DML, and particularly for INSERT-heavy applications, the index design should be
seriously reviewed, which might require a compromise between the query and
INSERT performance.

3. Multiple Columns

One of the advantage is that multiple bitmap indexes can be merged and the column does
not have to selective!

• More than one column in the table has an index that the optimizer can use to
improve performance on a table scan. (See reference 6)
• Combining bitmap indexes on non-selective columns allows efficient AND and OR
operations with a great number of rowids with minimal I/O. (Reference 5)
• ===================

RE: What is the diff b/w BTREE INDEX and BITMAP INDEX

Difference between B-Tree Index & Bitmap Index.

1. B-tree Index has low cardinality values where as Bitmap Index has High
Cardinality values.
2. B-tree Index is useful for OLTP where as Bitmap Index is useful for Data ware
Housing.
3. B-tree index updates on key values has relatively inexpensive where as Bitmap
index has more expensive.

Btree Index is very usefull for OLTP and BITMAP index are useful for Decision
Support System. When OLTP environment higly level DML activites where doing
and it is better to use Btree indexes is better than Bitmap indexes. Where as BITMAP
indexes is better for Decision support System because there will be few distinct
values.
=======================

Bitmap index:
------------
A type of index that uses a string of bits to quickly locate rows in a table. Bitmap indexes
are normally used to index low cardinality columns in a warehouse environment.

Btree index:
------------
A type of index that uses a balanced tree structure for efficient record retrieval. B-tree
indexes store key data in ascending or descending order.

You might also like