Should I store a calculate value in my database along with the variables?

前端 未结 5 826
囚心锁ツ
囚心锁ツ 2020-12-31 07:00

In all the applications I have made where a database is used I typically store the calculated value along with the variables needed to calculate that value. For example, if

5条回答
  •  一向
    一向 (楼主)
    2020-12-31 07:52

    Simple math is relatively cheap, however you need to weigh up the additional storage cost vs performance saving when storing these values. Another thing you may want to consider is the affect this will have on data updates, where you cant simply just update the field value, you need to update the calculated value too.

提交回复
热议问题