ClickHouse

Раздел про ClickHouse: колоночное хранение и MergeTree, моделирование схемы и materialized views, интеграция из Java/Spring, эксплуатация — репликация, TTL, мониторинг.

Why it matters for UCP. ClickHouse is the standard OLAP engine for analytics in the UCP stack: events, audit, product metrics, reports — everything that chokes a production PostgreSQL with analytical GROUP BYs. The fourth type of storage after relational, search, and object stores. Part of the training program.

The section is split into four articles: fundamentals (how it works and where it applies), modeling (schema and queries), integration (Java/Spring and the data pipeline), and operations. The examples use the same order/product domains as PostgreSQL and Elasticsearch, so the approaches are easy to compare.

Articles in this section

  1. Fundamentals: columnar storage, MergeTree, OLAP vs OLTP — why aggregating a billion rows takes a fraction of a second, parts and merges, the sparse index, and what ClickHouse lacks.
  2. Modeling and queries — choosing ORDER BY and PARTITION BY, data types, aggregation idioms, materialized views, ReplacingMergeTree, and antipatterns.
  3. Integration from Java/Spring — JDBC and a second DataSource, batch inserts, idempotency, the PG → outbox → Kafka → ClickHouse pipeline, Testcontainers.
  4. Operations: replication, sharding, TTL, monitoring — ReplicatedMergeTree and Keeper, Distributed tables, the data lifecycle, system tables, and common incidents.
  • PostgreSQL — the source of truth that ClickHouse complements but does not replace.
  • Elasticsearch — the neighboring specialized engine: ES for search, ClickHouse for aggregates.
  • Apache Kafka — the transport for the event pipeline into ClickHouse.
  • CQRS and distributed patterns — the read model, outbox, and eventual consistency the integration rests on.