Anton Dolganin

I'm an engineer focused on solving problems, not tied to any specific language. Architecture, development, DevOps — I choose the right tools for the job and build solutions that work in production and scale without pain.

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:

  • One value is rare (e.g. 1% are false)
  • Queries target only rare values

Better option: use a partial index

CREATE INDEX idx_inactive ON users (id) WHERE is_active = false;

PostgreSQL: Don't Rush to Index BOOLEAN Columns