MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Sort operation used more than the maximum 33554432 bytes of RAM

I’ve a Rails application that gets data from Mongo. It returns error when trying to export the data to csv -

error": “internal-server-error”,

“exception”: “Mongo::Error::OperationFailure : Executor error during find command :: caused by :: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit. (96)”

Created few indexes on the collection but its still throwing this error.

Any suggestions how to fix it?

Please make sure index exists on the sort field

Adding the index on the sort field fixed the issue. Thanks