質問

I have a table of purchase list with fields: ItemName, Quantity, UnitPrice, Amount. Note that Amount is equal to Quantity * UnitPrice.

My simple problem is, should I STORE the amount or COMPUTE it when retrieving the data? To what should I concern about, storage or processing?

役に立ちましたか?

解決

Storage is cheap, I'd just pre-compute it for convenience. It probably won't matter much depending on your application though unless you are searching or reporting on the Amount column. If you are reporting on this column then I'd definitely pre-compute. I'd be more worried about joins and sub-queries.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top