Selain index single-field dasar, MongoDB menawarkan strategi indexing lanjutan — compound index ordering (ESR rule), covered queries, partial/sparse indexes, TTL indexes, dan lainnya — yang secara dramatis mempengaruhi performa query. Menguasainya adalah kunci untuk mengoptimalkan MongoDB dalam skala besar.
Compound indexes dengan ESR rule
For a compound index supporting a query with Equality, Sort, and Range conditions,
order the fields: EQUALITY → SORT → RANGE (the ESR rule).
