Partial indexes cover only documents matching a filter. They suit focused workloads and conditional uniqueness.
Before you start
You should understand documents, collections and indexes. Sketch representative documents and the reads and writes they must support. MongoDB-specific examples assume a collection with the shown fields; deployment topology, permissions and existing indexes can affect the operational behavior being discussed.
The practical goal is to reason through this situation: Index active subscriptions when inactive history dominates the collection. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.
Step-by-step walkthrough
Step 1: Identify subset membership
Choose a filter describing active records precisely.
Step 2: Align application queries
Queries must imply the index’s coverage condition to safely use it.
Step 3: Measure lifecycle changes
Documents entering and leaving the subset affect index maintenance and size.
Worked scenario
Index active subscriptions when inactive history dominates the collection.
An active-subscription index excludes inactive history. Queries for active subscriptions can benefit, while an all-history report needs another access path. If most records later become active, the reduced-size advantage changes; conditional uniqueness also applies only to documents covered by the filter.
Common mistake
A query must satisfy the relevant filter conditions to benefit safely.
Verify the behavior
Compare active, inactive and mixed queries plus transitions across the filter boundary.
Interview exercise
Choose a partial-index workload.
Answer and reasoning
Measure the subset’s size and actual query forms, including how records enter and leave that subset.
Continue learning
Compare the scenario with the MongoDB interview questions and test your understanding with the MongoDB MCQs. For terminology and implementation details, consult the reference material.