I'm able to change the mongodb's-sort-buffer-size using below command
db.adminCommand({setParameter: 1, internalQueryExecMaxBlockingSortBytes: <limit in bytes>})
but, how to run the same command using mongoose library?
Try this:
YourModel.db.db.admin().command({setParameter: 1, internalQueryExecMaxBlockingSortBytes: <limit in bytes>}, function (err,res)
{
console.log(res);
});
Update:
You can also do it without YourModel
.
mongoose.connection.db.admin().command({setParameter: 1, internalQueryExecMaxBlockingSortBytes: 268435456}, function (err,result)
{
console.log(result);
});
Just make sure you do it after the connection has been established.
Recommendation:
While the above will work for you, if the query that needs this is a frequently used query, you should consider using indexing.