Compound Index
noun
say it: “KOM-pownd IN-deks” /ˈkɑmpaʊnd ˈɪndɛks/
A MongoDB index on two or more fields together, used by queries that start from its first field.
What is Compound Index?
A compound index covers several fields in order. It helps queries that filter or sort on those fields from the left.
db.orders.createIndex({ customerId: 1, placedAt: -1 })
In a sentence
- “The order of the fields in a compound index decides which queries it can serve.”
- “A compound index on customerId and placedAt serves 'Ana's orders, newest first'.”
Level: Journeyman · More MongoDB terms at this level
Updated