mongodb keep_mutation阶段讲解

mongodb keep_mutation stage explain

我使用 mongo 的 explain() 来检查一些查询的性能,有时 keep_mutation 阶段会如下所示:

  "executionStats" : {
            ...
            "executionStages" : {
                    "stage" : "KEEP_MUTATIONS",
                    "nReturned" : 1,
                    "executionTimeMillisEstimate" : 5460,
                    "works" : 79622,
                    ...
            }
   }

我想了解更多关于这个阶段的信息,所以我在网上搜索了一下,结果令我惊讶的是,即使在官方文档中也找不到与它相关的有用信息,更不用说其他网站了。有人可以帮忙解释一下吗?

KeepMutationsStage 传递其所有子项的数据,直到子项 EOF。然后它 returns WorkingSet 中通过阶段过滤器的所有标记元素。

此阶段用于在可能的情况下将查询中无效的结果合并回查询结果。查询规划器负责确定合并这些结果的有效时间。

Source

检查this

KEEP_MUTATIONS stage: When documents are deleted or updated some Query stages can receive invalidation notices. Some stages flag documents that are deleted. The set of flagged documents is then read by the KEEP_MUTATIONS stage, which re-checks these documents against the query and returns them if they still match. Note that this is not used for the WiredTiger engine, only for the MMAPv1.