A live window inside a materialized history
Cost reporting needs stable history and a live edge where people are still entering adjustments. The pattern materializes everything older than a short window and keeps the window itself as a view over live inputs.
- The problem
- A cost-of-sales report that was either slow, because it recomputed years of history on every refresh, or stale, because people's latest adjustments did not show up until the nightly build.
- The outcome
- History loads instantly and never changes without a deliberate rebuild; the last two weeks reflect every writeback as it happens.
The problem
Finance reports have two kinds of data: the past, which should be fixed and fast, and the present, where analysts are still correcting mappings, entering counts and reclassifying lines. Treating both the same way makes the report either slow or stale.
The pattern
- Split the model at a window boundary, for example fourteen days before today.
- Everything before the boundary is a materialized table, rebuilt only for the partitions a run announces, never as a side effect.
- Everything inside the window is a view over the live input tables, including the ones the business writes back into through its BI tool.
- The report model unions the two, so consumers see one table and never need to know where the boundary is.
- Tests assert that the two halves agree at the boundary, and that a materialized partition changes only when its rebuild was requested.
What it changes
Dashboards load from the materialized history and feel instant. The current period updates as people work. Rebuilds are cheap because they only touch announced partitions, and auditable because every rebuild is a logged request.
What carries over
The boundary and the union. Decide the window with the people doing the adjusting, not with the engineers.