Skip to content

Instantly share code, notes, and snippets.

@vanleantking
Created December 10, 2022 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanleantking/3c4e3617afeeaddefba97793bd1b4173 to your computer and use it in GitHub Desktop.
Save vanleantking/3c4e3617afeeaddefba97793bd1b4173 to your computer and use it in GitHub Desktop.
MongoDB aggregation allowUseDisk
MongoDB aggregation stage limits
Aggregation works in memory. Each stage can use up to 100 MB of RAM. You will get an error from the database if you exceed this limit.
If it becomes an unavoidable problem you can opt to page to disk, with the only disadvantage that you will wait a little longer because it is slower to work on the disk rather than in memory. To choose the page to disk method, you just need to set the option allowDiskUse to true like this:
db.collectionName.aggregate(pipeline, { allowDiskUse : true })
Note that this option is not always available shared services. For example Atlas M0, M2 and M5 clusters disable this option.
https://studio3t.com/knowledge-base/articles/mongodb-aggregation-framework/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment