Why do indexes slow down writes in MongoDB?
Because MongoDB has to update each index on every insert, update, and delete. Indexes are a tradeoff: faster reads, slower writes. Index only the queries you actually run; do not index every field.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in MongoDB Indexes Interview Questions and Answers
An index on two or more fields. MongoDB can use it for queries on any prefix of the indexed fields. Order matters: equality first, then sort, then range (ESR rule).
A compound index on (A, B, C) can be used for A, A+B, or A+B+C. It cannot be used for B, C, or B+C. If you query on B+C, you need a separate index on (B, C).
Run .explain('executionStats'). Look at winningPlan.stage (IXSCAN is good, COLLSCAN is bad) and executionStats.totalDocsExamined (should be small, close to the number of documents returned).
Still have questions?
Browse all our FAQs or reach out to our support team
