MongoDB schema for storing user location history

痞子三分冷 提交于 2019-12-22 18:24:53

问题


I'd like to use MongoDB to store my users location history (with their consent, of course). I see the following three options:

  1. 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.
  2. 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.
  3. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!