mongoDB get execution time of a query in microseconds
10,484
Refer to these links, they may be helpful for you
http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/
Related videos on Youtube
Author by
Matt
Updated on June 04, 2022Comments
-
Matt almost 2 years
I should get the execution time of a query in mongoDB. Using explain() I noticed that it is zero millis. So, Is it possible in mongoDB to obtain the execution time of a query in microseconds in a simple way? For example if I wanted to calculate mean and variance of a sample of 10k test queries (where each query lasts micros), how could I do? I'm using PHP.
-
Matt almost 10 yearsThe second link is about profiling; the first link is about explain() (that returns time in ms) and also profiling. This latter allows me to log additional infos like: lock and unlock time, execution time (in millis) etc. Two questions: (i) Is the execution time of a query the sum of these locks time? (ii) if I execute a query n times, the profile will record just few. Why?
-
Shahid Hussain almost 10 yearsans (i): the execution time doesn't include lock time, refer docs.mongodb.org/manual/reference/database-profiler and check system.profile.lockStats.timeLockedMicros. Ans(ii)db.system.profile.find() should show you all the records