Database Reference
In-Depth Information
Metric Collection Query Performance
MongoDB has a method called explain , which can be called on a
query to show the query plan that will be executed by a particular
query. This is particularly useful for debugging performance
bottlenecks in MongoDB environments.
For example, the query plan to search for the metrics from a particular
customer reveals that a scan would be required under the current
indexing scheme:
> db.metrics.find({customer_id:1}).explain()
{
" cursor" : "BasicCursor",
"isMultiKey" : false,
"n" : 1,
"nscannedObjects" : 1,
"nscanned" : 1,
"nscannedObjectsAllPlans" : 1,
"nscannedAllPlans" : 1,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
}
}
However, if the timestamp is used, the index used to implement the
time-to-live feature is used to improve performance:
> db.metrics.find({customer_id:1,ts:{$gt:new
Date(2013,11,01)}})
.explain()
{
" cursor" : "BtreeCursor ts_1",
 
Search WWH ::




Custom Search