3

I have a mongo query which have multiple lookup but it returns me a error

Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in

I already add allow disk size true in my aggregation query

await Service.aggregate(pipeline) .allowDiskUse(true) .exec();

6
  • What version of MongoDB are you using, and what sort of an aggregate operation are you performing? I don't think allowDiskUse works with all of them. Commented Jan 2, 2019 at 11:11
  • 1
    Are you connecting to a MongoDB deployment that you have installed, or a cloud service? If you are using a cloud service (particularly a free tier) the allowDiskUse option may not be supported. Commented Jan 2, 2019 at 11:27
  • @Caffeinated.tech version 5.2.7, services.aggregate([ { '$addFields': { name_lc: { '$toLower': '$name.value_en' } } }, { '$match': { isDeleted: false } }, { '$lookup': { from: 'servicecategories', localField: 'serviceCategory', foreignField: '_id', as: 'category' } }, { '$sort': { name_lc: 1 } }, { '$skip': 0 }, { '$limit': 10 }, { '$project': { 'category.defaultQuantities': 0 } } ], { allowDiskUse: true }) Commented Jan 2, 2019 at 11:34
  • @Stennie i am using mongo atlas paid Commented Jan 2, 2019 at 11:38
  • 4
    Is your paid Atlas cluster shared tier (M2 or M5)? The allowDiskUse option currently requires a dedicated cluster (M10+) - see Operational Limitations. Commented Jan 2, 2019 at 23:37

1 Answer 1

7

Is your paid Atlas cluster shared tier (M2 or M5)? The allowDiskUse option currently requires a dedicated cluster (M10+) - see Operation Limitation. NB. this is from @stennie

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, you saved a lot of my time. I was concerned that my syntax was wrong but in the end, I found out that my company had downgraded to an M5 (General) shared cluster for cost-cutting, which is why my allowDiskUse option was not working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.