MongoDB - 操作统计 - numYields

MongoDB - Operation Statistics - numYields

我在 collection 上有一个更新操作 运行,它涉及更新几百万行数据。我想监控这个操作的进度,已经转到当前操作视图

numYields 值似乎与数据库应该做的一致地增加,所以我想知道它是否在每次修改文档时增加(更新:Multi)。

根据 documentation:

Long running read and write operations, such as queries, updates, and deletes, yield under many conditions. MongoDB operations can also yield locks between individual document modifications in write operations that affect multiple documents like update() with the multi parameter.

但是,上面的段落并没有具体说明是文档的每次更新都会产生,还是偶尔会在几次更新中产生一次。

有人可以分享一下这个指标是否可靠,可以确定作为此 long-running 操作的一部分更新了多少文档?

Could someone share the light on whether this indicator is reliable for determining how many documents were updated as a part of this long-running operation?

否:numYields 仅表示长 运行 操作已产生。与并发更新没有直接关联,如 Does a read or write operation ever yield the lock?:

中所述,周期性屈服有多种原因
  • 避免长期存储事务,因为这些事务可能需要在内存中保存大量数据;
  • 用作中断点,以便您可以终止长时间的 运行 操作;
  • 允许需要独占访问集合的操作,例如 index/collection 掉落和创建。

However, the paragraph above does not specify whether each and every update on the document yields, or whether it happens occasionally once in a few updates.

屈服是周期性的,通常由经过的时间或 operations/iterations 的数量等指标决定。