Django:每天查看具有数万观看次数的跟踪数据
我有一个带有Postgres后端的Django应用程序。用户可以发表帖子并查看它们。
“景色”坐在每天的高数十万,每天总计100k+。我们想跟踪视图,以便我们可以过滤用户从他们的家庭时间表中看到的帖子。将来,这也将用于算法更好地向用户介绍内容。
我最初的想法是将这些视图存储在数据库中作为另一个表:
class PostView(models.Model):
post = models.ForeignKey(Post)
user = models.ForeignKey(User)
count = models.IntegerField(default=1)
但是,这会在几周内迅速淹没数据库,数十万(或数百万)的额外行(我相信这会压倒数据库吗?下降)?
人们是否有其他方式通常存储这种视图数据?还是我的方法有效地很好?
I have a Django app with a Postgres backend. Users can make posts and view them.
"Views" sit around the high-tens-of-thousands to 100K+ per day total. We want to track views so that we can filter out posts users have already seen from their home timeline. In the future, this will also be used for algorithmically surfacing content to users better.
My original thought was to store these views as rows in the database as another table:
class PostView(models.Model):
post = models.ForeignKey(Post)
user = models.ForeignKey(User)
count = models.IntegerField(default=1)
However this would quickly overwhelm the database with hundreds of thousands (or millions) of extra rows in weeks, (which I believe would overwhelm the database? Would or slow it down)?
Is there perhaps another way that people typically store this sort of view data? Or is my approach effectively fine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论