如果系统里每个用户都可以自己新建表,mongo里出现大量collection,如何避免?
发布于 11 年前 作者 CN-Sean 7551 次预览 最后一次回复是 11 年前 来自 问答
rt。 大家好, 我这里有个应用场景,就是每个用户可以在我开发的平台上自己定义数据表,然后填入数据,再自己做分析。那么也就是说用户的表相互直接结构都不相同。我这里有2个做法,一个是把所有用户定义的数据都放一个collection里,还有一个就是把每个用户自己表弄一个collection。数据量会越来越大,后者必定会造成大量的collection,所以我采用了前者。不知道我的做法是否合理? 还有个问题,如果我没有使用mongo,而是使用了mysql,是不是意味着我必须使用很多table了?mysql的很多table又会有问题吗? 不知道哪位大神可以给我很好的解答~~小弟拜谢了
7 回复
http://jsnoder.com/blog/mongodb-shi-yong-ru-men/
我想多个 collection 比一个大collection性能要好些。
@russj 这样子,我就会有大量的collection。mongo的collection个数有没有上限? 因为单个collection,我可以做shareding
@violet-day collection或者table的个数有上限么?
@CN-Sean 有的吧,具体要看什么db了吧,不过你的数据量不一定会触碰到上限
Number of Collections in a Database The maximum number of collections in a database is a function of the size of the namespace file and the number of indexes of collections in the database.
Namespaces Namespace Length Each namespace, including database and collection name, must be shorter than 123 bytes.
Number of Namespaces The limitation on the number of namespaces is the size of the namespace file divided by 628.
A 16 megabyte namespace file can support approximately 24,000 namespaces. Each collection and index is a namespace.
Size of Namespace File Namespace files can be no larger than 2047 megabytes.
By default namespace files are 16 megabytes. You can configure the size using the nsSize option.
比较复杂。得看 MongoDB 的设置
这个问题值得关注一下…