<!-- llms-explorer concept facts · https://llms-explorer.com/tree/partial-unique-indexes-for-soft-delete/ · pack 2026-10-22 · ~694 tokens -->

# Partial unique indexes for soft delete

> Source-anchored research for Partial unique indexes for soft delete. Run status: COMPLETED.

Parent: [MongoDB Compound Index Design: ESR, Selectivity, Covering and Multikey Bounds](https://llms-explorer.com/tree/mongodb-compound-index-design-esr-selectivity-covering-and-multikey-bounds/) · 3 facets · 6 facts · page: https://llms-explorer.com/tree/partial-unique-indexes-for-soft-delete/

## How it works

- MongoDB's planner uses a partial index for a read only when the query predicate implies the partial filter or a stricter subset; this affects read-index eligibility, while the unique partial constraint still governs writes. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/index-partial/)
- A March 2019 Stack Overflow query-plan report found that { soft_deleted_at: null } still produced a FETCH filter because the [null, null] index bounds also included undefined or missing values. Treat this as a version-specific example and inspect explain() when active documents may have both null and missing states. (low confidence) (verified as of 2019-03-04) — [source](https://stackoverflow.com/questions/54985673/mongodb-partial-indexes-avoid-filtering-stage-when-filtering-on-null-date)

## Problems, failure modes and limitations

- If a deleted record's key has been reused, restoring it to the active state makes it match the partial index again; MongoDB then rejects the restore with a duplicate-key error while another active record owns that key. The application needs a restore-conflict policy. (medium confidence) — [source](https://www.mongodb.com/docs/manual/core/index-partial/)
- Before building a partial unique index, remove duplicate keys among documents that match its active-state filter. MongoDB cannot build a unique index when existing indexed documents violate the key constraint. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/index-partial/)

## Facts and statements

- MongoDB enforces a unique constraint only among documents that match the partialFilterExpression. A soft-delete index such as { email: 1 } with unique: true and partialFilterExpression: { deletedAt: null } allows an active record to reuse an email after the old record receives a deletion timestamp, provided null represents the active state. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/index-partial/)
- For tenant-scoped uniqueness, use the tenant and normalized identifier as the compound unique key, such as { tenantId: 1, emailNormalized: 1 }, and use the soft-delete state in the partial filter. MongoDB applies compound uniqueness to the combination of indexed key values. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/index-unique/)
