问题
I'd like to use MongoDB to store my users location history (with their consent, of course). I see the following three options:
- Create one locations collection for all users. Each document would have a userId field, as well as a time field, both of which would be indexed. The number of rows in this collection could potentially grow beyond 100 million.
- Create one collection with users which have their locations as embedded array. That makes searching for locations a little more difficult, since MongoDB apparently doesn't support queries which return embedded documents.
- Create one collection per user with his/her location history. I'm aware of the limit of 24K collections for one MongoDB instance and I think that limit is tolerable for now.
I'd appreciate any feedback which helps me making the choice.
Thanks and cheers, Georg
回答1:
As mentioned in the comments above, I've chosen option 1 and have no regrets at this point. Thanks for your help.
Cheers, Georg
来源:https://stackoverflow.com/questions/9418633/mongodb-schema-for-storing-user-location-history