O'Reilly logo

Learning Mongoid by Gautam Rege

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

[conn32]

This is the client connection.

query

This is the command ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required