What is a partial (filtered) index, and when is it useful?
Last updated
A partial (filtered) index only indexes rows matching a
WHEREpredicate, making it smaller, faster to scan, and cheaper to maintain than a full index.Useful for hot subsets (e.g.
status = 'pending'), conditional uniqueness (one active record per user), or skipping manyNULL/default rows.The planner can use it only when the query predicate is implied by the index predicate. Otherwise it falls back to a full index or scan.
- https://neon.com/postgresql/indexes/partial-index
- https://www.postgresql.org/docs/current/indexes-partial.html
- https://learn.microsoft.com/en-us/sql/relational-databases/indexes/create-filtered-indexes?view=sql-server-ver17
- https://www.sqlite.org/partialindex.html
- https://www.youtube.com/watch?v=53CJUZ7rQ3E
- https://dev.to/damasosanoja/beyond-basic-indexes-advanced-postgres-indexing-for-maximum-supabase-performance-3oj1
- https://www.supascale.app/blog/database-indexing-for-selfhosted-supabase-a-complete-guide
- https://dev.to/mrpercival/partial-indexes-in-postgresql-24pb