Skip to main content

What is an index in MongoDB?

Entry MongoDB
Quick Answer An index in MongoDB is a data structure (B-tree) that speeds up queries by allowing MongoDB to find documents without scanning the entire collection. Without an index, every query does a full collection scan (COLLSCAN). Create an index on frequently queried fields: db.users.createIndex({email: 1}). Too many indexes slow down writes.

Answer

An index improves search performance on fields. Without indexes, MongoDB performs collection scans.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice