mongodb "_id" 索引总是保存在缓存中吗?

Is mongodb "_id" index always kept in cache?

我有一个 mongodb 数据库,其中有多个集合。还有一个额外的集合,它更像是系统中发生的所有事件的日志。我想知道,当我有一个很少使用的大集合时,当该集合上没有任何操作时,该集合的“_id”索引是否也会放入 RAM 中?或者它只是在磁盘上等待,直到执行读取操作。 我主要担心的是这个集合的大小是否会影响其他查询的性能(因为集合的大小比可用 RAM 大几倍)。

它们将在 LRU basis 上换出。

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.

To ensure this index fits in RAM, you must not only have more than that much RAM available but also must have RAM available for the rest of the working set. The indexes and the working set must be able to fit in memory at the same time.

https://docs.mongodb.com/manual/tutorial/ensure-indexes-fit-ram/#indexing-right-handed