Performance

MongoDB and a mystery of long running queries

MongoDB and a mystery of long running queries

Indexes are critical in MongoDB for optimal query performance, but they have some secrets!

Jerzy Czopek
In one of the projects I’m involved in, MongoDB is used to store data for services. We were seeing some unexpected behavior in one part of the system, and we were able to narrow down the issue to be a long-running query against one of the collections. Due to the size of that collection, the query was taking up to 2.5 hours! At first, it was obvious that we need an index of some sort to speed things up.