I am desgining a service where each authenticated user works with his own set of objects/documents, so the user accounts are completely separate. Does it make sense if I split the collections into individual per-user collecions or databases? Will it give me any speed or security advantages? Or should I just combine documents in common collections and let indexing and sharding do the work for me?
Share
For a small number of users you can do collection-per-user but for larger numbers you’d want to put them into the same collection. See http://www.mongodb.org/display/DOCS/Using+a+Large+Number+of+Collections
According to that page there aren’t any major performance penalties from using lots of collections.
From a security perspective you aren’t really gaining anything, any collection is as easy to access as any other, security is at the application-level for the most-part with MongoDB.
From a manageability perspective I’d put them in a single collection. That way you can run map-reduce jobs easily to summarize user stats.