### Using bitmap indexes

• How to use a bitmap index

• Example query:

• Find people (who by jewelry) such that:

 ``` age = 50 salary = 100 ```

 ``` 123456789012 =========================== Bitmap index for age = 50 = 001110000010 Bitmap index for salary = 100 = 000100000000 ----------------------- AND: 000100000000 Record #4 !!! ```

• Multi-dimensional nature of bitmap indexes

• Fact:

 When you have bitmap indexes on different fileds (of a record), the bitmap indexes are multi-dimensional There are some multi-dimensional queries that can be answered efficiently using bitmap indexes

• Answering partial match queries using bitmap indexes

• Query:

 Find people (buyers of jewelry) whose age = 50

Solution:

 ``` Bitmap index for age: Value 123456789012 ------------------------------ 25 100000001000 30 000000010000 45 010000000100 50 001110000010 <----- These people !!! 60 000000000001 70 000001000000 85 000000100000 Records: 3, 4, 5 and 11 ```

• Answering range queries using bitmap indexes

• Query:

• Find people (buyers of jewelry) where:

 ``` 45 ≤ age ≤ 55 100 ≤ salary ≤ 200 ```

Solution:

 ``` Bitmap index for age: Value 123456789012 ------------------------------ 25 100000001000 30 000000010000 45 010000000100 45 ≤ age ≤ 50 50 001110000010 60 000000000001 70 000001000000 85 000000100000 Or value = 011110000110 Bitmap index for salary: Value 123456789012 ------------------------------- 60 110000000000 75 001000000000 100 000100000000 110 000001000000 100 ≤ salary ≤ 200 120 000010000000 140 000000100000 260 000000010001 275 000000000010 350 000000000100 400 000000001000 Or value = 000111100000 (45 ≤ age ≤ 50) AND (100 ≤ salary ≤ 200): 123456789012 ======================= 011110000110 000111100000 (AND) --------------- 000110000000 Records: 4 and 5 ```