MongoDB get executionStats for aggregate query

Updated Answer:

From MonogoDB version 3.5.5, executionStats and allPlansExecution modes are supported in explain method with aggregation.

db.users.explain("executionStats").aggregate([]);

As per mongodb doc, You can view more verbose explain output by passing the executionStats or allPlansExecution explain modes to the db.collection.explain() method.

Old Answer:

Currently(MongoDB 3.2) aggregation does not support executionStats, with explain option in aggreagation you get some data related to query but there is no executionStats in it. It is proposed and you can check its status here

https://jira.mongodb.org/browse/SERVER-19758

Please upvote the issue if you want to implement this soon.


For me it works like this, you have this fixed in from version 3.5.5

It shows the execution plan and other metrics.

db.videos.explain('executionStats').aggregate([])

enter image description here