Large Collections Versus Large Numbers of Collections

Another important thing to consider when designing MongoDB documents and collections is the number of collections that the design will require. There really isn’t a significant performance hit for having a large number of collections, but there is a performance hit for having large numbers of items in the same collection. You should consider ways to break up your larger collections into more consumable chunks.

Say, for example that you store a history of user transactions in a database for past purchases. You recognize that for these completed purchases, you will never need to look them up together for multiple users. You only need them available for a user to look at his or her own history. If you have thousands of users who have a lot of transactions, then it makes sense to store those histories in a separate collection for each user.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset