5

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?

1 Answer 1

6

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.

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.