简体   繁体   English

MongoDB - 在同一个集合上有不同文档的缺点?

[英]MongoDB - Downside to having different documents on same collection?

What are the downsides of storing completely different documents on the same collection of MongoDB?在 MongoDB 的同一个集合上存储完全不同的文档有什么缺点?

Unlike others questions, the documents I'm referring to are not related (like parent-child).与其他问题不同,我所指的文件是不相关的(如父子)。

The motivator here is cost-reduction.这里的动机是降低成本。 Azure CosmosDB Mongo API charges and scalability are per-collection. Azure CosmosDB Mongo API 费用和可扩展性按集合计费。

  • The size of the collection will get a lot bigger a lot faster.集合的大小将更快地变得更大。
  • Speed of queries could be impacted as you'll have to scan more documents than required (could maybe use sparse indexes)查询速度可能会受到影响,因为您必须扫描比所需更多的文档(可能使用稀疏索引)
  • Index sizes will be a lot bigger and longer to scan索引大小将更大,扫描时间更长
  • You'll need to store a discriminator with the documents so you can tell what type one document is compared to another.您需要在文档中存储一个鉴别器,以便您可以判断一个文档与另一个文档的比较类型。

If the documents are not related at all, I'd store them in completely separate collections.如果文档完全不相关,我会将它们存储在完全独立的 collections 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MongoDb聚合框架,连接不同文档位于同一集合中 - MongoDb aggregation-framework, join different documents are in the same collection 如何将 MongoDB-atlas 集合中的特定文档与存储在同一集群中不同集合中的文档相关联? - How do I associate specific documents in a collection in MongoDB-atlas to documents that are stored in a different collection in the same cluster? 查询具有JSON文档数组的MongoDB集合 - Querying MongoDB collection having array of JSON documents 在MongoDB的集合中包含几乎相同大小的文档是否可以提高性能? - Do having documents of almost same size inside a collection in MongoDB improves the performance? 查询同一集合中的父子文档 MongoDB - Query documents with parent and child in same collection MongoDB MongoDB:检查该集合中所有文档中的字段是否相同 - MongoDB: Check if a field is same in all the documents in that collection MongoDB复制和更新同一集合中的多个文档 - MongoDB Copy and Update Multiple Documents in same collection MongoDB:$lookup 在后续文档中使用相同的集合 - MongoDB: $lookup with the same collection over subsequent documents 合并MongoDB中同一集合中的两个文档 - Merge two documents in the same collection in MongoDB 针对同一集合中的不同文档的不同TTL? - Different TTL for different documents that are in same collection?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM