[英]Query data every time or store values in table?
I have a table of players
with a field called scores
. 我有一张players
表,其中有一个名为“ scores
的字段。 Players gain different scores at different games. 玩家在不同的游戏中获得不同的分数。 Every few moments, I want to know total score gained by a certain player until then. 每隔几分钟,我想知道某个玩家在那之前获得的总得分。
Note that I want to do this action frequently. 请注意,我要经常执行此操作。
The question is, which way should I choose? 问题是,我应该选择哪种方式?
1) Define a field in my users table as player_score
and update it after each game finishes. 1)在我的用户表player_score
一个字段定义为player_score
,并在每个游戏结束后player_score
进行更新。
2) Every time I want to calculate total score of a player, query on all of the games and sum up the scores gained until now. 2)每当我想计算一个球员的总得分时,请查询所有游戏并总结到目前为止获得的得分。
Thanks for your help :) 谢谢你的帮助 :)
Depends on how much registrers you have on table games. 取决于您在桌上游戏中拥有多少注册者。 If you have too many records select will take longer. 如果记录太多,则选择将花费更长的时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.