© Anton Dolganin 2025
It might feel natural to index is_active — but in PostgreSQL, it often does more harm than good.
Why?
BOOLEAN has only three values: true, false, NULL.
If values are evenly distributed (e.g. 50/50), the B-tree index is inefficient. The planner will usually pick a sequential scan instead of using the index.
Index helps when:
Better option: use a partial index
CREATE INDEX idx_inactive ON users (id) WHERE is_active = false;
© Anton Dolganin 2025