索引是否使用指针? [英] Do indexes utilize pointers?

查看:42
本文介绍了索引是否使用指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mongodb 索引如何存储在 RAM 中?例如,如果有这样的文件:

How are mongodb indexes stored in RAM? For example, if there are documents like:

{fruit: 'apple', tags: ['hello', 'world', 'rainbow' ] }

{fruit: 'banana', tags: ['hello', 'world', 'unicorn' ] }

{fruit: 'orange', tags: ['hello', 'world', 'lion' ] }

tags 字段上带有索引.'hello''world' 标签是否会存储在一个单一的内存位置,然后让指针在索引中引用它们?或者是否为每个标签实例化了一个新的 String?

With an index on the tags field. Will the 'hello' and 'world' tags be stored in a single memory location and then have pointers reference them within the indexes? Or does a new String get instantiated for every tag?

推荐答案

来自 <代码>文档:

为了索引一个包含数组值的字段,MongoDB 为数组中的每一项添加索引项.

To index a field that holds an array value, MongoDB adds index items for each item in the array.

因此,为每个数组元素创建了单独的条目.

So, separate entries are created for each array element.

这篇关于索引是否使用指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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