I am trying to execute an execution query which has these stages:
$addFields
$group
$project
$merge
The collection on which I’m running the aggrregation query has 449.4k records and the collection size is around 200mb.
When I run the aggregation query I get an error message saying: PlanExecutor error during aggregation :: caused by :: Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in
As per the documentation, the limit for each aggregation pipeline stage is 100 MB. So, using allowDiskUse:true allows writing temporary files on disk when a pipeline stage exceeds the 100-megabyte limit. Starting in MongoDB 6.0, operations that require greater than 100 MB of memory automatically write data to temporary files by default.
So, here, I assume you are using a cluster < v6.0. Therefore, please ensure you are passing it syntactically correctly.