Skip to content

Commit 179b1d3

Browse files
committed
Index
1 parent 8a1cf6c commit 179b1d3

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,25 @@ db.accounts.dropIndexes()
12431243
<b><a href="#">↥ back to top</a></b>
12441244
</div>
12451245
1246-
#### Q. ***What happens if an index does not fit into RAM?***
1246+
## Q. ***What happens if an index does not fit into RAM?***
1247+
1248+
If the indexes does not fit into RAM, MongoDB reads data from disk which is relatively very much slower than reading from RAM.
1249+
1250+
Indexes do not have to fit entirely into RAM in all cases. If the value of the indexed field increments 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.
1251+
1252+
**Example**: To check the size of indexes
1253+
1254+
```js
1255+
> db.collection.totalIndexSize()
1256+
1257+
// Output (in bytes)
1258+
4294976499
1259+
```
1260+
1261+
<div align="right">
1262+
<b><a href="#">↥ back to top</a></b>
1263+
</div>
1264+
12471265
#### Q. ***Does MongoDB provide a facility to do text searches?***
12481266
#### Q. ***Where can I run MongoDB?***
12491267
#### Q. ***How to remove a field completely from a MongoDB document?***

0 commit comments

Comments
 (0)