Dev.to
8/4/2026

The original title is: "Diagnosing and fixing MongoDB latency spikes with profiler and ESR-indexing"
Original: The explain plan I read before the CEO called back!
Short summary
A practical walkthrough of diagnosing and fixing MongoDB latency spikes under time pressure. The author used the database profiler to identify a full collection scan on 200M documents running every five minutes, then applied the ESR (Equality-Sort-Range) rule to build a correct compound index with a partial filter expression. The fix resolved latency within six hours and the customer renewed.
- •Used MongoDB profiler to find a scheduled aggregation scanning 200M docs with no index
- •Applied ESR rule (Equality, Sort, Range) to build the correct compound index
- •Partial index on active-status records reduced index size and resolved latency
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



