如何检测我的查询结果是否从 WiredTiger 缓存中检索到?

How to detect if my query result is retrieved from WiredTiger cache?

我正在使用 Mongo 版本 3.4,存储引擎是 WiredTiger。 正如 document 所说,Mongo 确实将缓存用于适合 RAM 的工作集。

所以我的问题是

  1. 有什么方法可以检查我的查询结果是否来自缓存?
  2. 如果我的工作集大于 RAM 怎么办? Mongo 会清除缓存,还是会清除一些数据?
  3. 任何关于学习Mongo缓存机制的好资源的建议

WiredTiger缓存是为WiredTiger保留使用的内存的统称。此内存包含未压缩的集合数据、索引、"dirty" 内容(修改后的文档)等

回答您的问题:

Is there any way I can check if my query result is served from cache or not ?

任何查询都会导致 WiredTiger 以未压缩的形式将文档从磁盘加载到它的内存部分(so-called "cache")。因此 all 查询回复来自 "cache".

What if my working set is larger than RAM ? Would Mongo clear the cache, or would it evict some data ?

它会根据需要从缓存中逐出数据。如果需要逐出的数据是 "dirty",则在逐出过程中也需要将其写入磁盘。

Any suggestion for good resources to learn about Mongo caching mechanism

MongoDB 文档中有一些关于它的一般描述:

有关更多 in-depth 文档,请参阅 WiredTiger documentation