Wednesday, January 29, 2014

B Tree v/s Bit Map Indexes

BitMap v/s B-Tree Index?

If your table has low cardinality value (e.g. Gender column, boolean data), opt for a Bit Map Index.
If your table has high cardinality value, opt for a B-tree Index.

B Tree index is very useful in OLTP systems.
Bit Map works best in Data wareehousing systems.

In Bit Map structures, a two-dimensional array is created with one column for every row in the table being indexed.
Each column represents a distinct value within the bitmapped index.
Thus for low cardinality columns, they become very compact and fast to scan.

In B-tree, records are stored in locations called leaves. The starting point is called the root.
Its a tree where max number of children per node is called order.
Depth is the # of operations needed to reach the desired leaf

Consider below an example of a B-Tree with  

Order   = 2
Depth   = 3
Leaves = 4

                           [Root]
                                |
                                | 
                                |  
                                |  
                               / \  {Node]
                              /   \
                             /     \
                            /\     /\
                           /  \   /  \
                          /    \ /    \
                      [Leaves]

No comments:

Post a Comment