一个集合最多可以有多少个字段?

What is the max number of fields a collection can have?

集合可以处理的字段数是否有上限? 我有一个集合需要支持 300 个字段(因此每个文档将有 300 个字段)。

在这些字段中,只有两个字段需要编入索引,因为永远不会搜索另一个字段。 所以,我想,索引并不是一个限制因素。

MongoDB 文档的文档大小限制为 16 MB and a 100 levels limit of nesting, but the documentation does not specified the fields limit. For the fastest processing, ensure that your indexes fit entirely in RAM,这样系统就可以避免从磁盘读取索引。

一起访问的数据应该存储在一起,考虑到这一点,您应该考虑每个文档 300 个文件。