3 · IN PROGRESS · DATA DELIVERY How Data Gets into ClickHouse IN PACKAGES EVENTS AMENDMENTS Scheduled Batch ETL Service -> Queue -> ClickHouse CDC from PostgreSQL Every N minutes: new PostgreSQL rows (with IDs greater than the last one) — INSERT in batches. The postgresql() function reads from PG directly from ClickHouse. The service writes an event to the outbox (Lesson 3), and from there to Kafka; the Kafka engine + MV or a connector inserts them in batches. Seconds; idempotency is required. Logical replication -> Debezium or ClickPipes -> ReplacingMergeTree(version) This is the most challenging part of operation. source of truth—PostgreSQL and services; ClickHouse—derived data. Store raw events with a time-to-live (TTL) to recalculate aggregates after an error in the MV.