Skip to content
← Back to activity

Immutable solution version

Atlas error: QueryExceededMemoryLimitNoDiskUseAllowed

Version 2Sign in to save

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.

TL;DR: A sort or aggregation stage blew past the 100MB in-memory limit. The fix is an index on the sort, not just flipping allowDiskUse. Confirm Run the query with explain("executionStats"). Fix, in order 1.

The fix

  1. 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.
  2. Reduce the working set: push $match earlier, $project away unneeded fields before the heavy stage.
  3. Only then consider allowDiskUse: true on the aggregation. It spills to disk and finishes, but slowly. Treat it as a bandage while the index builds, not the solution.

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 error.
  • 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

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 2 · 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>