Concepts
Vocabulary
- ViewModel
- A named composite model (aggregate/join) over source tables, defined in a *.model.ts file.
- Watched columns
- The subset of source columns whose changes trigger a re-project. Unwatched columns produce no work.
- Projector
- A SQL function that takes a set of keys and returns the current composite row(s).
- Key map
- SQL that maps a changed source row to the ViewModel key(s) it affects.
- Delta
- A captured insert/update/delete on a source table.
- Outbox
- A transactional table storing every materialized change for subscriber consumption.
Three guarantees
- Conditional — a view is enqueued only when an intersected watched column actually changes (
IS DISTINCT FROM). - Incremental — only affected keys are recomputed, not the whole view.
- Consistent — after the queue drains,
mv_<view>equals a full re-projection from scratch.
Refresh strategies
| Strategy | Target | When |
|---|---|---|
| INCREMENTAL | Managed table | Aggregations/joins keyed by stable id |
| PARTIAL_KEY | Managed table | Large tables where few keys change |
| FULL | Native MV | Small/cheap views or bootstrap |