MongoDB Atlas 探查器 : What is "Num Yields"?

标签 mongodb mongodb-atlas

在 MongoDB Atlas 仪表板查询分析器中,有一个 Num Yields 字段。这是什么?

Screenshot

最佳答案

来自 Database Profiler Output文档页面:

The number of times the operation yielded to allow other operations to complete. Typically, operations yield when they need access to data that MongoDB has not yet fully read into memory. This allows other operations that have data in memory to complete while MongoDB reads in data for the yielding operation. For more information, see the FAQ on when operations yield.

基本上 MongoDB 中的大多数数据库操作都有一个“屈服点”,即它可以将控制权让给其他操作的点。这通常是等待从磁盘加载数据。

简而言之,如果您看到大量的产出,则意味着查询花费了大量时间等待从磁盘加载数据。原因通常是:

  • 返回或处理大量数据的查询。如果这是原因,请确保查询仅返回您需要的内容。然而,这在某些用例中可能无法避免(例如分析)。
  • 未使用正确索引的低效查询,因此服务器被迫始终从磁盘加载完整文档。如果这是原因,请确保您已创建支持查询的适当索引。
  • 服务器中的 RAM 较小,因此必须始终从磁盘加载数据。如果以上都不是,那么服务器对于手头的任务来说太小了。考虑升级服务器的硬件。

请注意,如果您不是一直看到它,那么高产量不一定是坏事。但是,如果您在定期运行的查询中看到这一点,那肯定不好。

关于MongoDB Atlas 探查器 : What is "Num Yields"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59589923/

相关文章:

python - pymongo - 序列化/pickle 连接或数据库对象

laravel - 在 Laravel Sail 8.0 环境中安装 Jenssegers/MongoDB

regex - 如何在 Jenssegers raw() 函数中正确应用正则表达式

Mongodb atlas搜索: how to make use of multiple analyzers for the same query string,以便至少返回一些结果

database - 什么时候需要提供CA文件?

node.js - 无法使用 Mongoose 在 MongoDB Atlas 数据库上读取/写入

javascript - 将 MongoDB 中的数据存储在变量中 - mongoose 和 node.js

javascript - 创建一个包含 Node.js、MongoDb 和 D3.js 的 Web 应用程序

mongodb - 错误 8000 (AtlasError) : '(Unauthorized) not authorized on admin to execute command

node.js - MongooseError : Operation users. insertOne() 缓冲在 10000ms 后超时”在 Mongo Db atlas 中