A price monitoring project produces a stream of observations: this product, at this store, in this context, cost this much when we looked. How you store that stream decides which questions you can answer later, and whether the answers are honest. There are three common designs: keep every observation, keep only changes as validity intervals, or keep one snapshot per period. Each is reasonable. Each also quietly loses something, and the loss is easy to miss until someone asks a question the table can’t answer.
Key takeaways
- Append-only observations keep every check, including the ones that found nothing new. They are the evidence; everything else can be derived from them.
- Change-only intervals (type-2 slowly changing dimensions) are compact and fast for “when did it change?” but hide gaps in observation unless you model them.
- Daily snapshots suit dashboards but lose time of day and can carry stale values forward.
- An interval you derived from observations says when you saw a price, not when the price was valid. Keep “last seen” separate from “replaced”.
- A practical default: store observations, derive intervals, and build snapshots as views.
The same history, three ways
Same product, three ways to remember it
Ten days of one product's price, observed every six hours with a two-day outage
The example shows the core problem. The collector missed two days. The observations table shows the gap plainly. A change-only table built from the same observations records $22.49 as valid from the first time it was seen until the first time $19.99 was seen. That interval runs straight through two days in which nobody checked, and the table looks just as certain about those two days as about any other. A daily snapshot job is worse: on outage days it either has nothing or repeats the last known value, which looks like a confirmed price.
Size and query trade-offs
Rows stored, by design
1,000 products, 90 days, a check every six hours, about 3% of products changing price per day
Data behind the chart
| Design | Rows |
|---|---|
| Observations + intervals | 363,621 |
| Append-only observations | 360,000 |
| Daily snapshots | 90,000 |
| Change-only intervals | 3,621 |
| Append-only observations | Change-only intervals (SCD2) | Daily snapshots | |
|---|---|---|---|
| One row means | One check of one offer in one context | One period during which the price stayed the same | The price on one day |
| Rows in the simulation | 360,000 | 3,621 | 90,000 |
| “Price at time t?” | Latest observation before t, with its age | Interval containing t | Row for that date |
| “When did it change?” | Needs a window function over the history | Directly: interval boundaries | To the day only |
| “Did we check on that day?” | Yes, directly | Only if you store last-seen times | Only if you store the observation time |
| Main risk | Size; queries need care | Intervals spanning gaps look certain | Stale values carried forward; intraday changes lost |
Row counts from a seeded simulation of 1,000 products over 90 days with a check every six hours; the change rate is an assumption. We did not benchmark query speed; that depends on engine, indexes and workload.
A schema that keeps the evidence
Store observations as the source of truth, with enough context to tell offers apart and enough provenance to explain any number later.
PostgreSQLCREATE TABLE price_observation (
source text NOT NULL,
product_id text NOT NULL,
variant_id text NOT NULL DEFAULT '',
seller_id text NOT NULL DEFAULT '',
context text NOT NULL, -- ZIP, store or market the page was priced for
observed_at timestamptz NOT NULL,
amount numeric(12,2), -- NULL when no price was shown
currency char(3),
availability text,
evidence_id text, -- pointer to the stored page or response
parser_version text NOT NULL,
PRIMARY KEY (source, product_id, variant_id, seller_id, context, observed_at)
); Then derive intervals from it, with one change from the textbook type-2 design: keep the last time each state was confirmed separately from the time it was replaced. The space between them is time you didn’t observe.
PostgreSQLCREATE TABLE price_state (
source text NOT NULL,
product_id text NOT NULL,
variant_id text NOT NULL DEFAULT '',
seller_id text NOT NULL DEFAULT '',
context text NOT NULL,
amount numeric(12,2),
currency char(3),
first_seen_at timestamptz NOT NULL, -- first observation of this state
last_seen_at timestamptz NOT NULL, -- latest observation that confirmed it
replaced_at timestamptz -- first observation of the next state; NULL if current
); Asking for the price at a given moment from observations is a single query. Return the observation’s age alongside it, so a stale answer is visible.
PostgreSQLSELECT DISTINCT ON (source, product_id, variant_id, seller_id, context)
source, product_id, variant_id, seller_id, context,
amount, currency, observed_at,
TIMESTAMPTZ '2026-10-01 12:00+00' - observed_at AS age
FROM price_observation
WHERE observed_at <= TIMESTAMPTZ '2026-10-01 12:00+00'
ORDER BY source, product_id, variant_id, seller_id, context, observed_at DESC; Daily snapshots then become a view or a materialized table built from the same source, carrying the observation time they used so that a stale value can be flagged rather than trusted.
If you use dbt snapshots
dbt’s snapshots implement type-2 slowly changing dimensions, with dbt_valid_from and dbt_valid_to columns. With the timestamp strategy they rely on a trustworthy updated-at column from the source; with the check strategy they compare chosen columns on each run, so validity starts when the snapshot ran and noticed the change, not when the price changed. Recent versions also let you choose how deleted source rows are handled. That is a fine tool for the derived interval layer. It is not a substitute for keeping the observations themselves, because a snapshot table cannot tell you which runs actually saw the product.
Time handling
Store times as timestamptz in PostgreSQL, which normalizes values to UTC and displays them in the session’s time zone. Record the time you observed the price, not the time your job started or the row was written, and keep the source’s own timestamps, when it provides any, in separate columns. Prices observed in a ZIP code or store context belong to that context; never merge them into one series. For the wider picture of a monitoring pipeline, see our competitor price monitoring guide.
Quick answers
What is the best database schema for price history?
A common robust pattern is to store every observation append-only as the source of truth, derive change intervals from it for fast change queries, and build daily snapshots as views for reporting.
What is an SCD type 2 table for prices?
A table that stores one row per period during which a price stayed the same, with a start and end time. It is compact, but intervals derived from observations can silently span periods when nobody checked.
Should I store a daily price snapshot?
As a reporting layer, yes. As the only record, no: it loses the time of day, misses changes within a day and can carry stale values forward during collection outages.
How much storage does append-only price history need?
It grows with the number of checks, not changes. In our simulation of 1,000 products checked every six hours for 90 days it was 360,000 rows, against a few thousand for change-only intervals.
How should I store timestamps for scraped prices?
Use timestamptz, record when the price was observed rather than when the job ran, and keep any source-provided timestamps in separate columns.
Price history with the evidence attached
We deliver observations with context and timestamps, so you can derive the history you need. See price monitoring or browse datasets.
