What problem does it solve?
It solves slow MongoDB performance caused by missing or poorly designed indexes, inefficient query patterns, and aggregation pipelines that waste work or memory.
Core Features & Use Cases
- Index strategy that matches query shapes: Applies compound index field ordering (ESR), prefix principle, and compound vs single-field choices to avoid COLLSCAN and in-memory sorts.
- Specialized index guidance: Recommends the correct index types for real workloads, including partial, sparse, TTL, unique, text, geospatial, hashed, wildcard, multikey, clustered, and hidden indexes.
- Explain- and profiler-driven optimization: Teaches how to interpret executionStats to confirm IXSCAN vs COLLSCAN, diagnose scan-to-return inefficiency, and validate improvements.
- Aggregation pipeline optimization: Improves stage ordering ($match/$project early), prevents document explosion ($unwind on large arrays), optimizes $lookup and recursive traversal ($graphLookup), and controls memory/spill behavior.
- Production rollout and safety: Helps plan index builds to minimize impact, and offers diagnostics like $indexStats, slow query log, $queryStats, plan cache, and MongoDB 8.0 query settings.
Quick Start
Use this skill to optimize a slow MongoDB query by identifying the COLLSCAN reason, selecting the most suitable index pattern, and validating the improvement using explain("executionStats").