Reputation: 3
I am currently learning about bitmap indexes and I am wondering if anyone could shed some light on a question I have come across.
Suppose you have a million record and a field "weekday" that can take only 7 values. how big will the bitmap index be?
My understanding of BitMaps would lead me to believe that you would take the unique fields (7) and multiply them by the number of records (1,000,000).
therefore you would have 7,000,000 bits as the size of the bitmap index.
is this correct?
Or what was pointed out to me by a friend was that each day would be stored as binary (001 Monday, 010 Tuesday, 011 Wednesday etc..) leaving us with 111 as the 7th day, and only taking up 3 bits as the size.
Any help on this would be greatly appreciated.
Upvotes: 0
Views: 2382
Reputation: 23
I know this is a quetions from 2016 but the accepted answer doesn't answer the question clearly. A bitmap will store the values such as:
.
.
.
That means that 7bits will hold the 7 weekday values. If we have 1.000.000 records then the size of the bitmap will be 1.000.000 * 7bits = 7.000.000 bits = 7.000 kbit or 6835.938 kibibit
Upvotes: 1
Reputation: 389
In bitmap 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. This two-dimensional array represents each value within the Index multiplied by the number of rows in the table.
Upvotes: 1