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 に答える