KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm new to mongodb and I'm facing a dilemma regarding my DB Schema design: Should I create one single collection or put my data into several collections (we could call these categories I suppose). Now I know many such questions have been asked, but I believe my case is different for 2 reasons: If I go for many collections, I'll have to create about 120 and that's it. This won't grow in the future. I know I'll never need to query or insert into multiple collections. I will always have to query only one, since a document in collection X is not related to any document stored in the other collections. Documents may hold references to other parts of the DB though (like userId etc). So my question is: could the 120 collections improve query performance? Is this a useful optimization in my case? Or should I just go for single collection + sharding? Each collection is expected hold millions of documents. If use only one, it will store billions of docs. Thanks in advance! ------- Edit: Thanks for the great answers. In fact the 120 collections is only a self made limit, it's not really optimal: The data in the collections is related to web publishers. There could be millions of these (any web site can join). I guess the ideal situation would be if I could create a collection for each publisher (to hold their data only). But obviously, this is not possible due to mongo limitations. So I came up with the idea of a fixed number of collections to at least distribute the data somehow. Like: collection "A_XX" would hold XX Platform related data for publishers whose names start with "A".. etc. We'll only support a few of these platforms, so 120 collections should be more than enough. On another website someone suggested using many databases instead of many collections. But this means overhead and then I would have to use / manage many different c
Tags (comma-separated)
Save Edits
Cancel