开发者

Optimize search efficiency with mongoDB nested collection?

开发者 https://www.devze.com 2023-03-24 02:10 出处:网络
Let us suppose we have the next data structure: { { \"name\" : \"ElementName1\", \"index\" : [ {\"name\" : \"key1\", \"value\" : 1},

Let us suppose we have the next data structure:

{
    {
    "name" : "ElementName1",

    "index" : [
         {"name" : "key1", "value" : 1},
         {"name" : "key2", "value" : 2},
         {"name" : "key3", "value" : 3}
        ]
    },
    {
    "name" : "ElementName2",
    "index" : [
         {"name" : "key1", "value" : 3},
         {"name" : "key2", "value" : 2},
         {"name" : "key3", "value" : 7}
        ]
    },
}

The idea is to have the best read performance possible. Let us suppose the priority on searching by name, so we ensure an ascending index on name (actually I've written a prototype and index considerably increases the search speed. This decreases the time for search from 1-2 sec to 0,1 sec for a million of really large documents.) The idea is to index the nested array fields somehow, but the problem is from what they write here, it is somehow impossible. I am trying to implement it using mongodb-csharp combination, but I suggest we do not specify the language. What are the possible increase options as I see:

  1. Implement this index in a way I am not yet aware of.
  2. Create one more collection for those array nested fields and index it in there.
  3. Other options.

Please sha开发者_开发百科re your view and ideas.

0

精彩评论

暂无评论...
验证码 换一张
取 消