Koskamo

Indexes for query performance

Document v1 · published by Koskamo editorial · updated 2026-10-04

Original source

Indexes support efficient execution of queries: without one, MongoDB must scan every document in a collection, while an appropriate index limits the number of documents scanned. But adding an index has a negative performance impact on write operations — for collections with a high write-to-read ratio, indexes are expensive because each insert must also update the indexes. Index fields your application repeatedly queries: a single-field index suits lookups like employee ID, an index on an embedded document is used only by queries that specify the entire embedded document (queries on a field within it do not), and a compound index covers multiple fields such as item and quantity. MongoDB indexes use a B-tree data structure, store values ordered by value to support efficient equality matches and range operations, and can return sorted results using the index ordering. MongoDB creates a unique index on _id during collection creation, which cannot be dropped. Manage indexes with a driver method, the MongoDB Shell, or the Atlas UI, Atlas CLI, and Performance Advisor, which recommends indexes for slow queries and ranks them by impact. Scope: MongoDB. Reviewed October 4, 2026.

Source and provenance

Original source
www.mongodb.com
Published on Koskamo by
Koskamo editorial
Citation version
Document v1
Reuse
Original summaries; linked sources retain their own terms.

The original source supplies the underlying information. Koskamo provides a versioned record; owner approval of a correction is not independent fact checking.