level 1
半知wzp
楼主
各位大佬,请问在monggodb同一集合中嵌入型字段里面的键值对可以不相同吗,对该集合的查询速度有什么影响吗?遇到一个问题,我早下面的例子中,同一集合下的部分文档中的嵌入式字段新增加了几个键值对,发现查询速度立马变慢,数据库cpu暴增?????是因为这个原因吗???????
例如:这样的 在同一个student集合中,包含以下文档student1 和student2, 期中other为嵌入型字段,在student2的里面的other嵌入式字段中多添加了两个address,sex键值对,并且在other字段不加任何索引:
第一个文档student1:
{
"name": 'xiaohpng',
“age”:12,
"other": {
"like": "music",
"sport": "football"
}
}
第二个文档student1:
{
"name": 'xiaohpng',
“age”:12,
"other": {
"like": "music",
"sport": "football"
"address": "nanjing",
"sex": "male"
}
}
2019年10月20日 03点10分
1
例如:这样的 在同一个student集合中,包含以下文档student1 和student2, 期中other为嵌入型字段,在student2的里面的other嵌入式字段中多添加了两个address,sex键值对,并且在other字段不加任何索引:
第一个文档student1:
{
"name": 'xiaohpng',
“age”:12,
"other": {
"like": "music",
"sport": "football"
}
}
第二个文档student1:
{
"name": 'xiaohpng',
“age”:12,
"other": {
"like": "music",
"sport": "football"
"address": "nanjing",
"sex": "male"
}
}