jiazou/4bp — comment on commit fa22fea2562c59d57b42e69c5deac2146636a607
File: Abp/base_model/models.py line 50
By zhanghao8301:

from what I understand ProductPriceHistory is a table that has three columns:
Product ID | DateTime | Price.

So if we store the, say price for product id = 1 for 6 days, then we need 6 rows to store all the information.

While this is feasible, SELECT will be quite expensive. For example, if we only use product id as the primary key, it means select will go through all the table rows to find those matched with a certain date range. If we use product ID AND datetime as primary key, then storing the database with two-keys chained won't be that efficient.

If we store everything as a field in the database, something like

Product ID | Serialized Price History

then it would be more efficient for future queries.