Incremental View Maintenance
Derive the signed delta of a join, then follow concurrent input changes, iterative dataflow, and the memory cost of incremental maintenance.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 3
- Reading time
- 2 min
In this article3 chapters
The delta is a relation with signed weights
A materialized view saves query results across updates. Represent each collection as a map from tuples to integer multiplicities. An insertion adds a positive weight and a deletion adds a negative weight. A join multiplies the weights of compatible input tuples, and projection sums the weights mapped to the same output tuple. These rules make the join bilinear. For old inputs \(R,S\) and their changes \(\Delta R,\Delta S\), expanding the join of the updated inputs gives
\[ \Delta(R\Join S) =(\Delta R\Join S)+(R\Join\Delta S)+(\Delta R\Join\Delta S). \]
If each input starts empty and a matching tuple arrives on both sides in one batch, only the last term produces an output. Sequential implementations capture that same term by using the updated first relation when applying the second change.
Bag semantics assign a multiplicity to each input value. Incremental join deltas put a sign on changes to those counts, including the term induced by updates on both sides.
State makes the delta inexpensive
A new record with key \(k\) can look up old matches in a maintained index. This replaces a full scan with work proportional to the local update and matching records. A hot key can still expand one input update into many output changes. A maintained aggregate counts multiplicities, and richer operators such as minimum may need additional state to choose a successor after deletion. Database provenance uses related algebraic rules for annotating the origin of each result.
Recursion needs progress and retained history
Differential dataflow distinguishes changes by partially ordered logical times. A tuple of input epoch and iteration coordinate can distinguish new input from further progress inside a recursive computation. Operators maintain indexed traces and compact history when older distinctions become irrelevant to future readers. Bounds on active timestamps and distinct keys matter for memory. Distributed stream processing adds another distinction between event time and the progress by which downstream operators may finalize results.[1][2]