Handling slow queries in MongoDB: Investigation

Click for: original source

Article by Justin Liu about one of the most essential factors of performance in any application – latency. Faster application response times have been proven to increase user interaction and engagement as systems appear more natural and fluid with lower latencies.

In this blog, we’ll explore a few key ways to understand and address slow queries in MongoDB. We’ll also take a look at some strategies on how to mitigate issues like these from arising in the future.

The MongoDB Database Profiler is a built-in profiler which collects detailed information (including all CRUD operations and configuration changes) about what operations the database took while executing each your queries and why it chose them. It then stores all of this information inside a capped system collection in the admin database which you can query at anytime.

The article then describes in some detail:

  • Identifying Slow Queries using the Database Profiler
  • Configuring the Database Profiler
  • Analyzing Performance Using the Database Profiler
  • Breaking Down & Understanding Slow Queries
  • Understanding and Evaluating Query Execution Plans

Often times, the only way to tackle bottlenecks is by helping “hint” the database into selecting a better query execution strategy or covering index by rewriting your queries (e.g. using derived tables instead of subqueries or replacing costly window functions). Great read!

[Read More]

Tags nosql miscellaneous performance devops software-architecture