Support multi-field filters and sorts.
Section: MongoDB index types
Compound index
javascript
javascript
db.orders.createIndex({ tenantId: 1, status: 1, createdAt: -1 })Explanation
Column order still matters in MongoDB compound indexes.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing MongoDB index types
Multikey index on an array field
Index documents that contain array values.
Wildcard index
Support flexible queries on unknown or varying fields.
Explain a query with execution stats
Inspect planner and runtime behavior.