Database Reference
In-Depth Information
responseLength : The length in bytes of the response.
millis : The number of milliseconds it took to execute the query.
ts : Displays a timestamp in UTC that indicates when the query was executed.
client : The connection details of the client who ran this query.
user : The user who ran this operation.
Because the system.profile collection is just a normal collection, you can use MongoDB's query tools to home
in quickly on problematic queries.
The next example finds all the queries that are taking longer than 10ms to execute. In this case, you can just
query for cases where millis >10 in the system.profile collection, and then sort the results by the execution time in
descending order:
> db.system.profile.find({millis:{$gt:10}}).sort({millis:-1})
{ "op" : "query", "ns" : "blog.system.profile", "query" : { }, "ntoreturn" : 0, "ntoskip" : 0,
"nscanned" : 1, "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r"
: NumberLong(60), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(4), "w" :
NumberLong(3) } }, "nreturned" : 1, "responseLength" : 370, "millis" : 12, "ts" : ISODate("2013-05-
18T05:40:27.106Z"), "client" : "127.0.0.1", "allUsers" : [ ], "user" : "" }
If you also know your problem occurred during a specific time range, then you can use the ts field to add query
terms that restrict the range to the required slice.
Increase the Size of Your Profile Collection
If you find that for whatever reason your profile collection is just too small, you can increase its size.
First you need to disable profiling on the database whose profile collection size you wish to increase, to ensure
that nothing writes to it while you are doing this operation:
$mongo
>use blog
>db.setProfilingLevel(0)
Next you need to delete the existing system.profile collection:
>db.system.profile.drop()
With the collection dropped, you can now create your new profiler collection with the createCollection
command and specifying the desired size in bytes. The following example creates a collection capped at 50MB.
It uses notation that converts 50 bytes into kilobytes and then into megabytes by multiplying it by 1024 for each
increase in scale:
>db.createCollection( "system.profile", { capped: true, size: 50 * 1024 * 1024 } )
{ "ok" : 1 }
With your new larger capped collection in place, you can now re-enable profiling:
>db.setProfilingLevel(2)
 
Search WWH ::




Custom Search