Beyond basic single-field indexes, MongoDB offers advanced indexing strategies — compound index ordering (ESR rule), covered queries, partial/sparse indexes, TTL indexes, and more — that dramatically affect query performance. Mastering them is key to optimizing MongoDB at scale.
The ESR rule for compound indexes
For a compound index supporting a query with Equality, Sort, and Range conditions,
order the fields: EQUALITY → SORT → RANGE (the ESR rule).
