0

So I have a very large set of metrics (15GB and growing) that has some of the data in nested hashes. Like so:

{
   _id: 'abc0000',
   type: 'foo',
   data: { a: 20, b: 30, c: 3 }
},
... more data following this schema...
{
   _id: 'abc5000',
   type: 'bar'
   data: { a: 1,  b: 2,  c: 4, d: 10 }
}

What is the performance implications when I run a query on the nested hashes? The data inside the hash can't be indexed...or rather, it would be pointless to index it.

I can always reform the data into a flat style data_a, data_b, etc...

4

1 回答 1

1

您可以在嵌套散列中的属性上创建索引。查看Indexing with dot notation了解更多详细信息。如果需要,您还可以创建复合索引,但要注意并行数组的注意事项。基本上,如果您创建一个复合索引,那么只有一个索引值可以是数组,但是,这不应该影响您(从发布的架构来看)。

data.a因此,您可以在上data.bdata.a, data.c根据您的需要创建索引。

于 2012-06-01T09:14:46.303 回答