Section: Create indexes

List indexes on a collection

javascript
javascript
db.users.getIndexes()
Explanation

Useful before adding more indexes or debugging an execution plan.

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 Create indexes
Create a single-field index
Index one frequently filtered field.
OpenIn sheetjavascriptsame section
Create a compound index
Index fields used together in filters or sorts.
OpenIn sheetjavascriptsame section
Enforce uniqueness with an index
Prevent duplicate values at write time.
OpenIn sheetjavascriptsame section
Create a text index
Enable text search over string content.
OpenIn sheetjavascriptsame section
Force a specific index with hint
Test how a query behaves with a chosen index.
OpenIn sheetjavascript2 tag match
Hide an index for testing
Temporarily hide an index from the planner.
OpenIn sheetjavascript2 tag match