CHAPTER 8 Indexes Indexes provide high performance read operations for frequently used queries. This section introduces indexes in MongoDB, describes the types and configuration options for indexes, and describes special types of indexing MongoDB supports. The section also provides tutorials detailing procedures and operational concerns, and providing information on how applications may use indexes. Indexes support the efficient execution of queries in MongoDB. 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. If an appropriate index exists for a query, MongoDB can use the index to limit the number of documents it must inspect. Indexes are special data structures 1 that store a small portion of the collection’s data set in an easy to traverse form. 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. In addition, MongoDB can return sorted results by using the ordering in the index. The following diagram illustrates a query that selects and orders the matching documents using an index: Fundamentally, indexes in MongoDB are similar to indexes in other database systems. MongoDB defines indexes at the collection level and supports indexes on any field or sub-field of the documents in a MongoDB collection. 1 MongoDB indexes use a B-tree data structure. 481 8.1 Index Introduction Index Introduction (page 481) An introduction to indexes in MongoDB. Index Concepts (page 486) The core documentation of indexes in MongoDB, including geospatial and text indexes. Index Types (page 486) MongoDB provides different types of indexes for different purposes and different types of content. Index Properties (page 503) The properties you can specify when building indexes. Index Creation (page 507) The options available when creating indexes. Index Intersection (page 510) The use of index intersection to fulfill a query. Indexing Tutorials (page 517) Examples of operations involving indexes, including index creation and querying in- dexes. Indexing Reference (page 552) Reference material for indexes in MongoDB.