MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Aggregation pipeline optimization tools

Hi!
I’m working on optimization slow aggregation pipelines. I use explain() method to show more details about what MongoDB do with this query, but it doesn’t give as many information as MsSQL.
Is there any other tools besides explain()? Something that can tell me which part of execution of pipeline takes the most of time?

Hi @Mateusz_Krawczyk,

When using MongoDB Compass, you have access to the Visual Explain Plan which can help you parse the explain results much more easily.

Hello Mateusz_Krawczyk,

The explain has different modes:

  • “queryPlanner”
  • “executionStats”
  • “allPlansExecution”

Each mode returns a query plan with different verbosity / details. You may want to try out and see which one suits your need. The default mode is “queryPlanner”.

The way to use is: db.collection.explain("...").aggregate( [ ... ] )

Reference: Information on Aggregation Optimization

1 Like