Is Mongo hogging all your CPU? It's probably because it's doing a lot of work to find your documents. This usually equates to adding an index to your collection.
Turn on profiling:
mongo
use dbname
// 0 = off, 1 = profile slow queries, 2 = profile all queries
// https://docs.mongodb.com/v3.2/tutorial/manage-the-database-profiler/#profiling-levels
db.setProfilingLevel(1)
Profiles then get put in the system.profile collection
system.profile is a capped collection so never gets too big
The important fields are the time taken, document examined and the query that was performed. Examining the query should give you an idea of what index(es) need to be added.
Note: Apply new indexes in a database migration, not directly on the server
Is Mongo hogging all your CPU? It's probably because it's doing a lot of work to find your documents. This usually equates to adding an index to your collection.
Turn on profiling:
system.profile
collectionsystem.profile
is a capped collection so never gets too bigGet the latest profile:
The important fields are the time taken, document examined and the query that was performed. Examining the query should give you an idea of what index(es) need to be added.
Note: Apply new indexes in a database migration, not directly on the server