04 Real-time aggregates · Instructor
Make the incremental MV behavior and midpoint semantics explicit.
macOS terminal: Run workshop commands in Terminal using zsh or bash.
Timing
20 minutes.
Talk track
- The MV processes inserted blocks; it does not rescan history on every dashboard refresh.
Statefunctions store partial aggregate states; matchingMergefunctions finalize them.- OHLC is quote midpoint only. Mixing order-level change prices and last trades would make the chart meaningless.
- The collector deduplicates before the MV sees rows;
ReplacingMergeTreeafter the fact would not undo aggregate double-counting.
Common failures
- Aggregate empty: verify raw midpoint rows exist and the MV was created before ingestion.
- MV created late: restart fixture mode after creating it, or accept only new rows.
- Old newest minute: check collector health before debugging SQL.
Reset
For a fresh aggregate without deleting raw data, recreate the target and MV, then allow
new events to populate it. Do not run OPTIMIZE TABLE FINAL.