Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Measure time of query in Mongo

How can I measure execution time of query in MongoDB ? I found Mongo-hacker plugin but it looks like it measure time of query including time of displaying all results. In PostgreSQL I use Explain Analyze SELECT ... , but i didn't found any information about time in mongo's db.collection.find({smth}).explain()

like image 850
Алиса Метелева Avatar asked Apr 15 '16 13:04

Алиса Метелева


People also ask

Which query is taking time in MongoDB?

One can identify slow queries in MongoDB by enabling the profiler and configuring it to its some specifications or executing db. currentOp() on a running mongod instance. By looking at the time parameters on the returned result, we can identify which queries are lagging.

How fast are MongoDB queries?

How fast are MongoDB queries? Pretty darn fast. Primary key or index queries should take just a few milliseconds. Queries without indexes depend on collection size and machine specs, etc.

What is timestamp in MongoDB?

Working of the timestamp in mongodb is simple, where when executed, the timestamp method will call the currentDate(), which will pick the current date and time of the system. This picked date and time will be stored in the collection, along with the other data values.


1 Answers

You can add .explain("executionStats") at the end of the query.

like image 192
Rohit Patwa Avatar answered Sep 28 '22 07:09

Rohit Patwa