mysql - Store computation results in database? -


how useful store "simple" computation results in (sql)-database?

lets make example:

  • the gross price is: 10.00$
  • taxes are: 20%
  • shipping costs are: 5.00$

from these informations can compute the:

  • net price: 12.00$
  • overall costs: 17.00$

the question is: should store 3 raw values , compute other 2 on every request or should compute them once , store them too?

in other words: more more valuable? computation power or storage space?

to question:

in other words: more more valuable? computation power or storage space?

to answer this, need consider use case of data, , trade-offs willing make speed , storage.

consider use case there 100 million records, , need run reports queries net price, overall costs. in case, reports run slower if values computed. now, if need reports run faster, can consider storing computed values in table.

as use case, if have above data, , have audit table stores every update data, , there archive jobs backup data periodically, end storing more data when computed values part of main table.

so answer depends on use case , trade-offs willing make.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -