Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find whether index is in RAM or Disk [MongoDB]?

What is best way to find whether an index in reside in RAM or Disk in mongodb?

like image 293
Arunoda Susiripala Avatar asked Nov 25 '12 14:11

Arunoda Susiripala


1 Answers

On one hand, it is entirely possible only some parts of the index is in RAM http://docs.mongodb.org/manual/applications/indexes/#indexing-right-handed

Indexes do not have to fit entirely into RAM in all cases. If the value of the indexed field grows with every insert, and most queries select recently added documents; then MongoDB only needs to keep the parts of the index that hold the most recent or “right-most” values in RAM. This allows for efficient index use for read and write operations and minimize the amount of RAM required to support the index.

On the other hand, db.serverStatus() gives you an aggregate of the information you wanted. Check http://docs.mongodb.org/manual/reference/server-status/#server-status-indexcounters:

The indexCounters.btree.hits value reflects the number of times that an index has been accessed and mongod is able to return the index from memory.

like image 158
chx Avatar answered Sep 22 '22 12:09

chx