结构数据的最佳方法仅显示用户未见记录
假设您有一系列视频,您想跟踪用户看过这些视频的内容,并确保用户不会再次看到这些视频,或者最少会优先考虑用户在上面看过的视频。做这件事的最佳方法是什么?
在SQL中,我通常会使用左联接来完成此操作,并从消除用户看到的视频开始,但即使这也可能开始下降的性能。我知道我应该能够通过创建两个集合来做到这一点。一个用于视频,一个用于视图并使用查找,但我不确定是否有更好/更性能的方法来完成此任务。
Say you have a collection of videos and you would like to track what users has seen those videos and make certain that the users do not see those videos again or at bare minimum prioritize videos that a user hasn't seen above those that they have seen. What would be the best way to accomplish this that would scale?
In SQL I would typically use a left join to accomplish this and start by eliminating videos that the user has seen, but even this could start to decline in performance. I know that I should be able to do this by creating two collections. One for the videos and one for the views and use a lookup, but I wasn't sure if there was a better/more performant way to accomplish this task.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,您应该将有关视图的数据存储在与电影同一集合中:
您可以在
userviewed
字段上简单地创建(Multikey)索引,以轻松过滤用户值。如果
Userviewed
列表开始增长,并且您不需要常规电影查询的数据,则可以将其存储在单独的集合中。电影的常规查询将更快,但是要根据视图进行过滤,您需要执行额外的$ lookup
。用户ID
索引将再次有所帮助。Generally, you should store data about views in the same collection as movies:
You can simply create (multikey) index on
userViewed
field to easily filter user values.If the
userViewed
list starts growing, and you don't need the data for regular movies querying, you can store it in separate collection. Regular queries on movies would be faster, but for filtering based on views you would need to do extra$lookup
. Index onuserId
will help again.