Is there any other way to get the aggregation query execution time metrics in MongoDB atlas?

510 views Asked by At

Having read that MongoDB Atlas is high performant, I'm eager to know the Execution Time differences between my aggregation queries run on my local MongoDB Server and on my MongoDB Atlas instance. Hence I have set up a M0(Free Tier) MongoDB Atlas Database.

In my local MongoDB Server, I can see the aggregation query execution time using the following command:

db.collection.explain("executionStats").aggregate([
{ $match....},
{ $facet...},
...])

My collection contains 10k documents with nested arrays and complex aggregation query.Execution time is almost 30 seconds.

But when it comes to MongoDB Atlas, it is specified in the doc that Atlas M0 Free Tier clusters do not support the helper methods like explain() for the aggregation command. So I cannot see the execution time.

Is there any other way to get the aggregation query execution time metrics without upgrading?

1

There are 1 answers

0
Tiya Jose On BEST ANSWER

It can be done simply using a Javascript function.

d = new Date; 
db.coll.aggregate(...); 
print(new Date - d + 'ms')