Monitoring query performance
MongoDB provides a lot of tools for monitoring performance of the database. By default, it is configured to log only slow queries—those that consume more than 100 ms in database operations. It's very important to monitor these logs.
If you see any query
commands taking a long time, in most cases it means that the fields need to be indexed as follows:
[conn23] query sodibee_development.authors query: { $query: { ... } ntoreturn:10 ntoskip:0 nscanned:17158 scanAndOrder:1 keyUpdates:0 numYields: 1 locks(micros) r:272157 nreturned:10 reslen:20221 169m
This query log has some interesting information as shown in the following table:
Expression |
Description |
---|---|
|
This is the client connection. |
|
This is the command that was fired. It can be |
|
This is the database and the collection on which this query was fired. |
|
This is the actual query that was fired. |
|
This is 1000 unless... |