Is there any way we can figure out what all indexes are cached into RAM ? I want to know page related stats for individual indexes (# of hits and miss )
Mongodb – How to find MongoDB index statistics
indexmongodb
Related Question
- Mongodb – How to index dynamic attributes in MongoDB
- Postgresql indexes in memory
- MongoDB Insert Performance
- Mongodb crash after WiredTiger Cannot allocate memory error
- MongoDB Audit – Is There a MongoDB Handler for Find Event?
- Sql-server – Correcting a database that has had indexes and statistics created on it willy-nilly
- Mongodb – Transfer image files from MongoDB to S3
Best Answer
You can get overall (instance wide) hit info from the
db.serverStatus()
command, and in particular:http://docs.mongodb.org/manual/reference/command/serverStatus/#serverStatus.indexCounters.hits http://docs.mongodb.org/manual/reference/command/serverStatus/#serverStatus.indexCounters.misses
These numbers are totals seen for the lifetime of the process, so if you want to get a rate or see the trend over time, then you will need to record them periodically and diff the values accordingly. Thankfully, if you install MMS Monitoring, it will do that for you and graph the results.
However, there are currently no per-index statistics available. The relevant feature request can be found here for tracking and voting purposes:
https://jira.mongodb.org/browse/SERVER-2227
Update: January 2016
The stats referenced above have been removed from the output of the server status command, so are no longer available. However, the referenced feature request is now complete and is available in version 3.2 in the form of the
$indexStats
aggregation operator (the linked docs also contain sample output). For completeness, here's an example I put together:Prior to any queries I have just 2 indexes, the default
_id
andindexme
, both with 0 ops:Then run a couple of finds to bump the ops on
indexme
and check again: