juniorMongoDB

What is an Index in MongoDB?

Updated May 1, 2026

Short answer

Indexes are special data structures that store a small portion of the collection's data set to improve query speed.

Deep explanation

Without indexes, MongoDB must perform a 'collscan' (scanning every document). Indexes (typically B-trees) allow the engine to find records faster.

Real-world example

Indexing the 'username' field to make login lookups instantaneous.

Common mistakes

  • Over-indexing, which slows down write operations (inserts/updates).

Follow-up questions

  • What is a compound index?

More MongoDB interview questions

View all →