简体   繁体   English

MongoDB集合数组限制

[英]Mongodb collection array limit

I have several hundred JSON files with thousands of JSON array data on each files. 我有数百个JSON文件,每个文件上都有数千个JSON数组数据。 These are the historical price data for things like CORN, OIL etcs 这些是诸如玉米,油等的历史价格数据

I am confused if I should create a MongoDB collection for each file(it can be as much as 1K files), for example CORN, OIL etcs or should I create one MongoDB Collection called ASSETS and then create an array called OIL, CORN etcs and import those JSON files? 我是否应该为每个文件创建一个MongoDB集合(它可以多达1K个文件),例如CORN,OIL等,还是应该创建一个名为ASSETS的MongoDB集合,然后创建一个名为OIL,CORN等的数组,我感到困惑导入那些JSON文件?

I think and want to create one Collection called ASSETSand then add CORN, OIL data on array(So for example, I can fetch array like ~ASSETS.CORN...) but I am not sure what is the limit of MongoDB collection's array. 我想并想要创建一个名为ASSETS的Collection,然后在数组上添加CORN,OIL数据(例如,我可以获取〜ASSETS.CORN ...这样的数组),但是我不确定MongoDB集合的数组的限制是多少。 The array can grow to more than 100K. 该阵列可以增长到100K以上。

I do not want to create 1K+ collections just to store historical data but I think keeping it on array would look clean. 我不想创建1K +集合只是为了存储历史数据,但我认为将其保留在数组中看起来会很干净。

This question is not for us to answer, since we don't know what the data will be used for. 我们不回答这个问题,因为我们不知道数据将用于什么。

I will answer the question on how big a MongoDB Collection can be. 我将回答有关MongoDB集合有多大的问题。
In this document you can find that a collection has no maximum number of documents, unless you set the threshold which, if set, is not bigger than 2^32 documents. 此文档中,您可以发现一个集合没有最大文档数,除非您设置阈值(如果设置了该阈值),该阈值不大于2 ^ 32个文档。

Don't be worried using a single collection, since even if you would cap it, 100k is not even near 2^32! 不用担心使用单个集合,因为即使您将其设置为上限,100k也不接近2 ^ 32!

Databases themself are capped though! 虽然数据库本身受到限制! It is still 32TB of files, which is probably way more than you will fill with your data. 它仍然是32TB的文件,可能远远超出了您填充数据的范围。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM