Exceeded memory limit for $group, but didn't allow external sort

I have an issue when execute query have group and sort for large data about 15 thousand record
“Exceeded memory limit for $group, but didn’t allow external sort. Pass allowDiskUse: true to opt-in.”
this is an error that I’m facing, and I’m trying to use {allowDiskUse: true} but it didn’t work
How I can fix it?
note: I’m using Shared Clusters for development environments and low-traffic applications M2

Hello @Walaa_Medhat, welcome to the MongoDB Community forum!

The usage of the aggregate option allowDiskUse is not supported on the shared M2 Cluster configuration of Atlas. See Atlas M0, M2 and M5 tier limitations, which says:

Atlas Free Tier and shared clusters do not support the allowDiskUse option for the aggregation command or its helper method.

1 Like

Oops, So if Use M10 it’ll work well?

According to the documentation linked in my earlier comment the M10 tier allows usage of the the aggregate option allowDiskUse. You can also contact Atlas Support for additional information - you will find the Online Chat and Support links within the Atlas portal you log into.

1 Like