Skip to content

Instantly share code, notes, and snippets.

@saintc0d3r
Created June 29, 2014 20:23
Show Gist options
  • Save saintc0d3r/c83feead6cc9181dae62 to your computer and use it in GitHub Desktop.
Save saintc0d3r/c83feead6cc9181dae62 to your computer and use it in GitHub Desktop.
How identify a query's performance though reading Mongod's log
// Suppose, we have 10000000 documents stored in bar collections (foo database)
use foo
for(var i = 0; i< 10000000; i++)(db.bar.insert({'a':i, 'b':i, 'c':i}))
// Let's pretend that we have an application that accesses foo.bar and perform this query
db.bar.find({'a':506785})
// Now, we want to peek how long did the query finish its job through peeking the mongod's log
// Focus on the command line box that runs mongod. You should notice a line that similar to mine at below:
// 2014-06-30T04:13:08.193+0800 [conn1] query foobar.foo query: { a: 555666.0 } planSummary: COLLSCAN
// (continued) ntoreturn:0 ntoskip:0 nscanned:10000000 nscannedObjects:10000000 keyUpdates:0 numYields:9600
// (continued) locks(micros) r:6802891 nreturned:1 reslen:75 11287ms --> Elapsed time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment