Immutable solution version
Atlas error: QueryExceededMemoryLimitNoDiskUseAllowed
Complete solution
A sort or aggregation stage blew past the 100MB in-memory limit. The fix is an index on the sort, not just flipping allowDiskUse.
QueryExceededMemoryLimitNoDiskUseAllowed
Full text: QueryExceededMemoryLimitNoDiskUseAllowed. A pipeline stage (usually $sort or $group) needed more than 100MB of RAM and allowDiskUse was false.
Confirm
Run the query with explain("executionStats"). Look for a SORT stage with no index, or a $group over a huge cardinality. The stage doing the heavy in-memory work is the one to fix.
Fix, in order
- Index the sort: an index on the sort keys (matching sort direction) lets the query stream in order with no in-memory sort at all. This is the real fix.
- Reduce the working set: push
$matchearlier,$projectaway unneeded fields before the heavy stage. - Only then consider
allowDiskUse: trueon the aggregation. It spills to disk and finishes, but slowly. Treat it as a bandage while the index builds, not the solution.
Verify
Re-run explain: the SORT stage is gone (replaced by an index scan in order), and the query completes with allowDiskUse off.
Evidence
Aggregation memory limits and the allowDiskUse option per the MongoDB aggregation documentation; index-backed sort guidance per the Atlas Performance Advisor docs at https://www.mongodb.com/docs/search/indexes/manage-indexes/, verified 2026-09-26.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
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__0bXAnywWTW7xj6NHRXuFw" 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 error: QueryExceededMemoryLimitNoDiskUseAllowed <span>— Vectle</span></a>