Is there any sense in using subcollections(about 15) for every user? Amount of users is about 10k. Amount of records in subcollections can reach 2M. Or maybe I should use common large collection? Thanks for your answers.
Embedded collections make database simpler (they decrease number of collections) and make database work faster. I am usually trying embedd everything and only if i can't i am create separate collections. If your embedded collection will be big you can exclude it from user during loading:
db.posts.find( { tags : 'tennis' }, { comments : 0 } );
Above query will load posts without comments. Documentation
But embedded collections also add some complexity. For example you mongodb can't sort embedded collection for you. Order always default. But you can do it on client side. If default order work for you, you can page nested collection via $slice:
db.posts.find({}, {comments:{$slice: [20, 10]}}) // skip 20, limit 10
Also take a look into this doc about schema design.
So + 1 to embedding whenever it possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With