IT lexicon › Database › Partial index

Partial index

Database På svenska → Updated: 2026-05-28

An index that covers only a subset of rows, defined by a WHERE condition. CREATE INDEX ON orders (created_at) WHERE status = 'pending'. Smaller index, faster, cheaper to maintain.

Use case: index only the "interesting" rows. Classic: soft-delete (WHERE deleted_at IS NULL → the index ignores deleted rows), active jobs in a queue (most are done/archived), unique constraints on a subset (UNIQUE ... WHERE active allows multiple inactive duplicates). Win: if 99% of rows are "done" the index becomes 100x smaller. The planner uses it only when the query's WHERE matches/implies the index condition. SQL Server calls it a "filtered index". Distinct from an expression index (which indexes a computation, not a subset). A very common Postgres optimization.

← Back to the lexicon