MongoDB Index Types and Query Patterns/Explain a query with execution stats

Inspect planner and runtime behavior.

Section: Verify with explain

Explain a query with execution stats

javascript
javascript
db.orders.find({ tenantId: 7, status: "paid" }).sort({ createdAt: -1 }).explain("executionStats")
Explanation

Check keys examined, docs examined, winning plan, and whether the compound index is actually used.

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 Verify with explain
Single-field index
Fast equality lookups on one field.
OpenIn sheetjavascript1 tag match
Compound index
Support multi-field filters and sorts.
OpenIn sheetjavascript1 tag match
Multikey index on an array field
Index documents that contain array values.
OpenIn sheetjavascript1 tag match
Partial index
Index only documents matching a filter.
OpenIn sheetjavascript1 tag match
TTL index
Expire documents automatically after a period.
OpenIn sheetjavascript1 tag match
Wildcard index
Support flexible queries on unknown or varying fields.
OpenIn sheetjavascript1 tag match