3

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?

Srinivas
  • 147
  • 3
  • 15

1 Answers1

4

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.

Dushyant Bangal
  • 6,048
  • 8
  • 48
  • 80