索引是否使用指针? [英] Do indexes utilize pointers?
问题描述
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屋!