mongoui
Performance·July 3, 2026·7 min read

MongoDB performance optimization: a practical checklist

Most MongoDB performance work is the same handful of moves in the same order: find the slow queries, read the plan, fix the index, model the schema for your reads, reclaim the storage. Here is the checklist, with the deep dive behind each step.

Arctic Glass illustration for MongoDB performance optimization: a practical checklist

Most MongoDB performance work is not exotic. It is the same handful of moves, in roughly the same order, applied where the numbers point. Before you reach for a bigger cluster or a shard key, walk this checklist. The scaling meeting cancels itself more often than anyone admits, usually around step two.

The one rule that runs through all of it: measure, do not guess. Every step below produces a number, and the number tells you whether the next step is worth doing.

1. Find the slow queries

You cannot fix what you have not found. The database profiler and the slow query log tell you exactly which operations are slow, ranked, so you are not guessing from the application code. Turn on the profiler, sort system.profile by millis, and you have a worklist, worst first. The full how-to is finding slow queries in MongoDB.

2. Read the plan and fix the index

Take the worst offender and run explain("executionStats"). A COLLSCAN with totalDocsExamined far above nReturned is the classic tell: a query reading the whole collection for want of an index. Add the index it needs, usually a compound index ordered Equality, Sort, Range, and the scan becomes a lookup. This single step fixes the majority of MongoDB slowness. The walk-through is why your MongoDB query is slow.

3. Prune the indexes nothing uses

Optimization is not only adding indexes; it is removing the ones that cost writes and return nothing. Run $indexStats, find the indexes sitting at zero uses across a full traffic cycle, and drop them. Every index you keep is a tax on every insert and update, so the target is the smallest set that covers your queries, which is the whole idea behind index optimization.

4. Filter aggregations early

Aggregation pipelines go slow when they do the expensive work before the cheap work: scanning the whole collection, then filtering. Move $match and $sort to the front so they can use an index, index the $lookup foreign field, and watch the 100MB sort limit. The details are in aggregation performance.

5. Model the schema for your reads

Some performance problems are not indexes at all; they are a schema fighting your access patterns. Embedding data you read together saves a join; referencing data that is large or shared keeps documents lean; the design patterns (attribute, bucket, computed) solve the recurring cases. Start from how to design a MongoDB schema, and catch the drift that quietly breaks queries after the fact.

6. Reclaim the storage

Performance and storage are cousins: a collection that is mostly dead weight is slower to scan and more expensive to hold. Understand storageSize versus your live data, expire old documents with a TTL index, and reclaim space with compact. The full version is storage optimization.

Then measure again

Re-run the profiler. The list is shorter. Re-run explain() on what you fixed; the COLLSCAN is an IXSCAN now, and the examined-to-returned ratio is close to one. If a change did not move the numbers, it did not help, and it is better to know that than to stack another guess on top. That is the whole loop: find, fix, measure, repeat.

Or run the scan

mongoui's Smart Scan runs this checklist in one pass: it surfaces the slow queries and the missing indexes behind them, flags the indexes nothing uses, shows where storage went and what is reclaimable, and reports schema drift, all read straight from your database. Its Query Optimizer reads each plan and names the index that fixes it. Full documents and MongoDB credentials stay local. Local narration makes no provider call; explicit AI narration sends the authored query and bounded structural plan context directly to your selected provider. The checklist is the method; the scan is the same method with the tedium removed. Either way, measure, do not guess.

Frequently asked questions

How do I optimize MongoDB performance?

Work in order: find the slow queries with the profiler, read each one's plan with explain(), add the index it needs, prune the indexes nothing uses, filter aggregations early, model the schema around your reads, and reclaim storage. Measure at each step rather than guessing, because the plan tells you which problem you actually have.

What is the most common MongoDB performance problem?

A missing index. Most slow MongoDB queries are a single collection scan that one index fixes. Before scaling the cluster or adding a shard, read the query plan: a COLLSCAN with far more documents examined than returned is the usual culprit, and a matching index turns it into a fast lookup.

Does adding more indexes make MongoDB faster?

Up to a point, then it makes writes slower. Each index speeds up the reads it serves and taxes every write that touches the collection. The goal is the smallest set of indexes that covers your real queries, not the largest, so pruning unused indexes is as much a part of optimization as adding needed ones.

How do I know if my MongoDB optimization worked?

Re-measure. Re-run the profiler and the query's explain(): the plan should show an IXSCAN instead of a COLLSCAN, and documents examined close to documents returned. If the numbers did not move, the change did not help, and guessing again will not either.