Section: MongoDB index types

Partial index

javascript
javascript
db.orders.createIndex(
  { createdAt: -1 },
  { partialFilterExpression: { shippedAt: { $exists: false } } }
)
Explanation

A strong way to shrink index size for hot subsets such as unshipped orders.

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
Single-field index
Fast equality lookups on one field.
OpenIn sheetjavascriptsame section
Compound index
Support multi-field filters and sorts.
OpenIn sheetjavascriptsame section
Multikey index on an array field
Index documents that contain array values.
OpenIn sheetjavascriptsame section
TTL index
Expire documents automatically after a period.
OpenIn sheetjavascriptsame section
Wildcard index
Support flexible queries on unknown or varying fields.
OpenIn sheetjavascriptsame section
Explain a query with execution stats
Inspect planner and runtime behavior.
OpenIn sheetjavascript1 tag match