Skip to Content
We are live but in Staging 🎉

BITMAP Index

A bitmap index speeds up filtering on low-cardinality scalar fields — fields that have a small number of distinct values (for example: is_public, status, category, tier, region).

Instead of scanning every record to evaluate a filter, a bitmap index precomputes compact bitsets and uses fast bitwise operations (AND/OR/NOT) to narrow results.

When to use BITMAP

Use a bitmap index when:

  • You filter heavily on a field with few distinct values (roughly < 500 unique values is a good rule of thumb).
  • Your queries often combine multiple filters (example: status == "active" AND is_public == true).

Avoid bitmap indexes when:

  • The field has high cardinality (like user_id, session_id, timestamps, or random strings). In that case, the bitmap becomes large and the benefit drops.

How it works (simple intuition)

Imagine a collection with category and is_public.

  • For category = "tech", the engine keeps a bitmap like: [1, 0, 1, 0, 0]
  • For is_public = true, it keeps another bitmap like: [1, 0, 0, 1, 0]

To answer:

category == "tech" AND is_public == true

it performs a fast bitwise AND on those bitmaps to find matching records—without scanning the full dataset.

Create a BITMAP index

In Dodil, you create scalar indexes through the VBase client.

Note: The exact method names may vary slightly by SDK version. If yours differs, keep the same intent and parameters: field_name, index_type="BITMAP", and index_name.

# Build index params index_params = vbase.create_index_params() index_params.add_index( field_name="category", index_type="BITMAP", index_name="category_bitmap_index", ) # Create the index vbase.create_index( collection_name="my_collection", index_params=index_params, )
Last updated on