What index is created automatically in MongoDB?
By default, MongoDB automatically creates an index on the _id field.
This index:
- is unique (a collection can't have two documents with the same
_id) - is created together with the collection
- is used for fast lookups by
_id, as well as when updating and deleting documents by that field
So, even if you never explicitly create any indexes, a collection always has { _id: 1 }, a B-tree index that provides fast access to a document by its identifier.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.