← Lessons

quiz vs the machine

Platinum1760

Databases

Bitmap Index Deep Dive

Representing low cardinality columns as bit vectors for fast boolean combining.

6 min read · advanced · beat Platinum to climb

Bits Per Value

A bitmap index represents each distinct value of a column as a bit vector with one bit per row. The bit is set when that row holds the value. A column with four distinct values produces four bitmaps, each as long as the table.

Why It Excels At Low Cardinality

Bitmaps shine on low cardinality columns like region, gender, or status. With few distinct values the index stays compact, and modern compression schemes shrink long runs of zeros dramatically.

The real strength is combining predicates. Filtering on region equals west AND status equals active becomes a bitwise AND of two bitmaps, a hardware speed operation that yields the matching rows directly. OR and NOT map to bitwise OR and complement.

The Write Cost

Bitmap indexes are weak for high write workloads. Updating a single row may require modifying multiple bitmaps, and locking tends to be coarse, blocking concurrent writers. They are therefore a staple of read mostly analytic warehouses, not transactional systems.

Key idea

A bitmap index stores one bit vector per distinct value, making boolean predicate combining a bitwise operation, ideal for low cardinality read mostly analytic columns.

Check yourself

Answer to earn rating on the learn ladder.

1. Which workload suits a bitmap index best?

2. How does a bitmap index combine two equality predicates joined by AND?

3. Why are bitmap indexes poor for frequent updates?