← all posts
DEEP DIVE11 Jun 2026·1 min read

Partial indexes in Postgres that cut 40% of p95

The hottest query in the system always filtered by status = 'pending' — less than 2% of the rows. The full index on status was almost useless: the planner preferred seq scan because the index was indexing 98% junk.

migrations/0042_partial_idx.sql
undefined

A partial index indexes only the rows the query actually looks for: 50x smaller, always in cache, and the planner starts using it. The endpoint p95 dropped 40% without touching a single line of application code.

Drizzle supports partial indexes in the schema via .where() on the index builder — you can version it alongside the rest.

← back to blogBernardo Filipe · 11 Jun 2026