mongoDB get execution time of a query in microseconds

10,484

Refer to these links, they may be helpful for you

Track MongoDB performance?

http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/

Share:
10,484

Related videos on Youtube

Matt
Author by

Matt

Updated on June 04, 2022

Comments

  • Matt
    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
    Matt almost 10 years
    The 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
    Shahid Hussain almost 10 years
    ans (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