January 29, 2013

Understanding BITMAP is so easy

1. Syntax

CREATE BITMAP INDEX index_name ON table

2. An simple example

TABLE test(id, name address){ (1,Rob,New York) (2,Mary,Orlando) (3,Jason,Chicago) (4,Lisa,New York) (5,Kim,New York) (6,Philip,Washington) (7,Frank,New York) (8,Elizabeth,New York) (9,Klaus,New York) ... }
if you want to find the result under the condition of 【Where address = 'New York'】,however, many rows meet the condition and then you won't get the benefits from the general index for efficient query. Here, you can create BITMAP INDEX:
New York Orlando Chicago Washington
1 0 0 0
0 1 0 0
0 0 1 0
1 0 0 0
1 0 0 0
0 0 0 1
1 0 0 0
1 0 0 0
1 0 0 0

In this case,  select * from TABLE where address = "New York"  will be quickly execute to find the resultset according to "1" and "0".

No comments:

Post a Comment