Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we always use allowDiskUse:true in MongoDB aggregation query

Aggregation pipeline stages have a limit of 100 MB. To handle large datasets, allowDiskUse enables writing to temporary files. But have this optional any defect? If haven't, why the default is false?

like image 734
songjhh Avatar asked Sep 16 '25 14:09

songjhh


1 Answers

The performance impact described in the answer from @prasad_ still holds true (hard-drive or storage will be slower than memory).

However, starting in MongoDB 6.0 the behavior of allowDiskUse has changed as it now defaults to true. That is, unless one explicitly disallows disk use with allowDiskUse(false) MongoDB resorts to disk use for (non-index) sorts requiring more than 100 MB memory.

like image 193
Dave Avatar answered Sep 18 '25 10:09

Dave