MongoDB Indexes, Explain Plans, and Performance/Force a specific index with hint

Test how a query behaves with a chosen index.

Section: Explain and tune

Force a specific index with hint

javascript
javascript
db.orders.find({ status: "paid" }).hint({ status: 1, created_at: -1 })
Explanation

Helpful for diagnostics, but avoid overusing hints in app code unless there is a strong reason.

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 Explain and tune
Hide an index for testing
Temporarily hide an index from the planner.
OpenIn sheetjavascriptsame section
Drop an index
Remove an unneeded index.
OpenIn sheetjavascriptsame section
Explain a query
Show the execution plan for a `find()` query.
OpenIn sheetjavascriptsame section
Inspect collection stats
View storage and index metrics for a collection.
OpenIn sheetjavascriptsame section
List indexes on a collection
Inspect existing indexes.
OpenIn sheetjavascript2 tag match
Create a single-field index
Index one frequently filtered field.
OpenIn sheetjavascript1 tag match