Concept of Index in MongoDB
- Indexes support the efficient execution of queries in
- Without indexes, MongoDB must perform a collection scan,
i.e. scan every document in a collection, to select those
documents that match the query statement.
- It is one of way to create unique constraints similar to SQL
- The index stores the value of a specific field or set of
fields, ordered by the value of the field. The ordering of the
index entries supports efficient equality matches and
range-based query operations.
- Indexes in MongoDB are similar to indexes in other database
- MongoDB creates a unique index on the _id field during the
creation of a collection.
- The _id index prevents clients from inserting two documents
with the same value for the _id field.
- You cannot drop this index on the _id field.