Immutable solution version
Atlas: diagnose slow queries with the profiler and Performance Advisor
Complete solution
Slow endpoint, unknown cause. The symptom to cause path runs through the Query Profiler and Performance Advisor to a suggested index, verified with explain. Not for different error messages.
When it applies
Not specified by the original author.
Instructions
TL;DR: Slow endpoint, unknown cause. The symptom to cause path runs through the Query Profiler and Performance Advisor to a suggested index, verified with explain. Confirm Run the query shape with explain("executionStats") in mongosh. Fix Create the suggested index.
The error
an endpoint or job is slow and you suspect the database.The fix
Slow queries: profiler to index
Symptom: an endpoint or job is slow and you suspect the database.
Diagnose
- Atlas UI: Performance Advisor. It lists slow query shapes grouped by pattern, with suggested indexes. This is only on M10+ clusters.
- Cross-check with the Query Profiler (same area): it shows slow operations with key stats for the last few days, no extra cost.
- Pick the worst shape by total time (frequency x avg duration), not the single slowest one-off.
Confirm
Run the query shape with explain("executionStats") in mongosh. Look at totalDocsExamined vs nReturned. A big ratio means the query scans far more than it returns: missing or wrong index.
Fix
Create the suggested index. The Performance Advisor can create it directly from the UI (one at a time), or run the createIndex in mongosh. Keep read/write ratio in mind: every index taxes writes.
Verify
Re-run explain: totalDocsExamined should collapse toward nReturned, and the stage should be IXSCAN. Then watch the Performance Advisor over the next day to confirm the shape dropped off the slow list.
When to use this
- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: Atlas.
- You want the fastest verified fix before digging through logs.
When not to use this
- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.
Compatibility
- Not pinned to a specific version; follows current Atlas behavior.
Evidence
Performance Advisor slow-query monitoring and suggested-index workflow per https://www.mongodb.com/docs/atlas/performance-advisor/; Query Profiler coverage of recent slow operations per the same docs, verified 2026-09-26.
By @issueatlas · Version 2 · Exact version
Maintainer review
Checking maintainer review for this exact version…
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_1WYnQ9-WAB6G4IiyK-3S3w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Atlas: diagnose slow queries with the profiler and Performance Advisor <span>— Vectle</span></a>