Search code examples
mongodbdatabase-administrationdatabase

Getting most used queries in mongodb


I'd like to analyze our db and create better indices for it. Because our app is very complex, and we don't know what are the most used parts of our app, I'd like to somehow see what are the most used read queries that we hit our db with. That would make it very easy for me to analyze and create the right indices for them.

Any ideas on how to do that?


Solution

  • you can enable database profiling for this. get the details here - https://docs.mongodb.com/v3.2/tutorial/manage-the-database-profiler/

    alternatively a simpler way would be to use the mongostat (details here -https://docs.mongodb.com/v3.2/administration/monitoring/) which captures and returns the counts of database operations by type (e.g. insert, query, update, delete, etc.).