MongoDB查找带有参数的查询是否将整个文档加载到内存中? [英] MongoDB find query with parameters loads whole document in memory or not?

查看:278
本文介绍了MongoDB查找带有参数的查询是否将整个文档加载到内存中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MongoDB中,当我们将字段名称作为查找查询的第二个参数传递时,mongodb是否将整个文档加载到内存中或仅加载与那些字段关联的内存?

In MongoDB, when we pass field names as the second parameter for find query does mongodb load whole document in memory or only the memory associated with those fields ?

推荐答案

在MongoDB服务器端,整个文档都存储在磁盘上的一个位置.由于MongoDB使用内存映射文件,因此任何文档访问都需要将整个文档加载到内存中.查询运行后,仅将请求的字段传输到客户端.这意味着在客户端/驱动程序端,只有请求的字段存储在内存中,而不是整个文档

On the MongoDB server side, the whole document is stored in one place on disk. Because MongoDB use memory mapped files, any document access requires that whole document to be loaded in memory. After the query has run, only the requested fields are transferred to the client. This means that on the client/driver side, only the requested fields are stored in memory, and not the whole document

这篇关于MongoDB查找带有参数的查询是否将整个文档加载到内存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆