0

Is it ok to precompute data for better performance? For example, when player wins a game, I count number of won games for the particular player and write it to a dedicated table. Then, when I show overall ratings, I don't need to count number of won games for the players once again — I already have it precomputed.

Of course, it's possible, that precomputed data becomes unsyncronized with real values, but it's bearable.

Or is there another, more "professional" way to resolve the issue?

4

2 回答 2

4

No, its perfectly fine and is mostly done for large datasets you'd else had to perform sum/count/group by statements that cost alot performance.

if "out of sync" is not a problem to realtime, use nightly-jobs to verify they are still in sync, or update them if they are not.

于 2012-09-03T15:10:35.147 回答
0

使用不同的方法 -

  1. 将聚合值存储在单独的汇总表中
  2. 根据原始表存储聚合值

没有正确或错误的答案。可能在你的情况下你想使用 1) 所以你有一个聚合表,比如​​:

PlayerID AggregateName AggregateValue

然后,您可以轻松扩展聚合,而无需修改表结构。

于 2012-09-04T02:21:30.277 回答