Storing Price Time Series: Three Schemas Compared

Step chart of one product's observed price over five days above three database tables: append-only observations, change-only price intervals and a daily snapshot

4 min read

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

What actually happenedAppend-only observationsChange-only intervalsDaily snapshotsday 0day 2day 4day 6day 8day 10collector outage$24.99$22.49$19.9932 checks, gap visible$22.49 'valid' through days with no checkscarried forwardSynthetic product. Dashed line: the true price, which the collector never sees directly.
Synthetic example by JsonEngine. Graphic: JsonEngine.

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

Observations + intervals363,621 rowsAppend-only observations360,000 rowsDaily snapshots90,000 rowsChange-only intervals3,621 rows
Seeded simulation by JsonEngine; change rate is an assumption. Circle area is proportional to row count. Graphic: JsonEngine.
Data behind the chart
DesignRows
Observations + intervals363,621
Append-only observations360,000
Daily snapshots90,000
Change-only intervals3,621
Append-only observationsChange-only intervals (SCD2)Daily snapshots
One row meansOne check of one offer in one contextOne period during which the price stayed the sameThe price on one day
Rows in the simulation360,0003,62190,000
“Price at time t?”Latest observation before t, with its ageInterval containing tRow for that date
“When did it change?”Needs a window function over the historyDirectly: interval boundariesTo the day only
“Did we check on that day?”Yes, directlyOnly if you store last-seen timesOnly if you store the observation time
Main riskSize; queries need careIntervals spanning gaps look certainStale 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.

PostgreSQL
CREATE 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.

PostgreSQL
CREATE 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.

PostgreSQL
SELECT 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.