A single-column index, called a single-field index in MongoDB, stores values from one document field in sorted order. It is useful when an application frequently queries that field. The field can be at the top level or inside an embedded document. section 7.2.1
db.movies.createIndex({"runtime": 1 })
Create an ascending index on movies.runtime with createIndex(). The value 1 specifies ascending order; -1 specifies descending order. section 7.2.1
Check that the index helps the intended query:
- Run db.movies.getIndexes() to confirm that runtime_1 exists alongside the automatically created _id index. section 7.2.1
- Run db.movies.find({ runtime: 100 }).explain("executionStats"). An IXSCAN on runtime_1 followed by FETCH shows the index locating matches before MongoDB retrieves their documents. section 7.2.1
- Inspect plans rather than assuming every predicate benefits equally: single-field indexes may offer limited benefit for $ne, $nin, and $not. section 7.6.5 section 7.8
A single-field index can also have a time-to-live (TTL) role. For a date field, createIndex({ date: 1 }, { expireAfterSeconds: 31536000 }) makes documents expire one year after the indexed date. Use 0 when the field contains each document’s intended expiration time. section 7.4.3

