Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with memory limit : Sort exceeded memory limit of 104857600 bytes, #2110

Closed
karimElb opened this issue Sep 26, 2020 · 6 comments
Closed
Labels
Needs investigation Need investigation about bugs described in issue

Comments

@karimElb
Copy link

karimElb commented Sep 26, 2020

Hi I have issue when loading data from mongodb using Sort option
I got this message "message: "multiplanner encountered a failure while selecting best plan :: caused by :: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in."
"
I know that the memory limit excited and I have to set allowDiskUse to True, I tried this :

...
->orderBy('created_at',$dir)
->options(['allowDiskUse' => true])
->get.....

But it's not working I got the same error.
Is there any solution to resolve this issue.

@divine
Copy link
Contributor

divine commented Sep 27, 2020

Increase your PHP memory limit. I can't really reproduce this.

@divine divine added the Needs investigation Need investigation about bugs described in issue label Sep 27, 2020
@karimElb
Copy link
Author

@divine I already did, but the issue is related to mongodb.

Aggregation pipeline stages in mongodb have maximum memory use limit. To handle large datasets, we need to set allowDiskUse option to true to enable writing data to temporary files

What MongoDb is saying here is that aggregate like sort has a maximum of RAM configured, but when exceeded instead of abort the operation it will continue using disk file storage instead of RAM, if the allowDiskUse has been set to true.

db.getCollection('movies').aggregate( [ { $sort : { year : 1} } ], { allowDiskUse: true } )

But how we can change the value to true in Laravel ?

@divine
Copy link
Contributor

divine commented Sep 28, 2020

Can you please dump that query? Does it contain { allowDiskUse: true } ?

@aabraham88
Copy link

which version of laravel-mongodb are using?

@SocolaDaiCa
Copy link

you need create index before sort. example

db.user.createIndex({ country: 1 });

@divine
Copy link
Contributor

divine commented Jan 24, 2021

Closing as not related.

@divine divine closed this as completed Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs investigation Need investigation about bugs described in issue
Projects
None yet
Development

No branches or pull requests

4 participants