Skip to content

What is cumulative table design?

A pattern that accumulates historical metrics via incremental FULL OUTER JOIN, avoiding a full rescan of the window each run.

Cumulative table design is a technique that stores a summary of each entity's history (a customer, for instance) and updates it with new data instead of recomputing all the source data every time. The summary can hold, for example, an ordered sequence of daily values from which recent activity can be derived. In the approach described in the reference repository, the day's events are first grouped by user, then joined with the previous day's summary. The sequence has a capped length: once it is full, each new value pushes out the oldest one. Weekly active users cannot be counted by adding up every user's active days; each user active at least once in the period counts exactly once. The technique can reduce repeated reads of raw events, but it requires storage for summaries, plus procedures for handling late-arriving data and reruns.

See also: Star schemaA star schema organizes data for analysis into a central fact table, which holds the measurements, and into dimension tables that describe their context.

How the summary is updated

The public example uses a FULL OUTER JOIN, which keeps rows found on only one side. As the PostgreSQL documentation on joins explains, columns from the missing side are null. The join keeps both new users and known users who were inactive that day; a zero for inactivity must be assigned deliberately, only when missing data really means no activity.

The sequence must stay in date order and use the same definition of a day on every update. Order cannot be assumed: the PostgreSQL aggregate documentation says that, without an ORDER BY in the aggregate, the order of aggregated values is unspecified. A simple running total can be enough for lifetime sums, but on its own it cannot rebuild a rolling window or count distinct users.

An enterprise example

A support platform wants to track active users and requests by customer. Each day it groups events by customer and updates a daily sequence, including customers with no events. For active users, it keeps per-user state instead and counts each user active in the window exactly once. A periodic check compares the results with a recomputation from the original events; if a day is reprocessed, the republished output must replace the previous result.

Boundaries and corrections

An event may arrive after the day it belongs to. The Apache Beam guide distinguishes event time from processing time and describes late data. Teams must decide how long to accept it and how to rebuild subsequent summaries with a backfill that does not duplicate results. The technique can coexist with a star schema, while slowly changing dimensions address the history of attributes.

Why it matters for decision makers

Benchmark the approach against direct recomputation on the real queries: measure reads, writes, storage, runtime, and the cost of corrections. Savings are not guaranteed and depend on the engine, volume, and window length. If the queries run rarely or change often, a simpler approach may be preferable. Adoption requires clear ownership of data quality, historical rebuilding, and retention.

Frequently asked questions

No. It must retain enough information to identify each active user in the window and count that user only once.

Define a policy for accepting them and correcting the affected day, then rebuild the subsequent summaries that depend on it.
  • Star schemaA star schema organizes data for analysis into a central fact table, which holds the measurements, and into dimension tables that describe their context.
  • Slowly Changing Dimensions (SCD)Slowly Changing Dimensions are techniques for managing changes to descriptive data over time and choosing which historical values to keep for reporting.
  • Medallion architectureA convention organizing lakehouse data into three layers of increasing quality: bronze (raw), silver (cleaned), gold (business-ready).
  • Data engineeringThe discipline that designs and builds data pipelines and platforms: the foundation BI, machine learning and generative AI stand on.

See it in the universe

If it touches your company's data, getting that data in order is the first thing I do.

See Data Foundations

Or write to me.