문제

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