Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 26 min read How-to mediumAdept

Modeling Machine Learning Data in OLAP databases

ClickHouse can act as the transformation engine and offline store of an ML feature store, with features modeled as timestamped tables and assembled into point-in-time correct training sets. Using a 100m-row web analytics dataset and a bounce-prediction example, the walkthrough builds a deduplicated "feature subset" table with ReplacingMergeTree and a trimmed PRIMARY KEY, then keeps it current with incremental materialized views. Features are tied to entities such as user and domain, computed with GROUP BY aggregations, and joined into feature vectors via ASOF JOIN on key and timestamp proximity. The aim is fast iteration during feature engineering, which usually costs more time than model selection.

Related posts

  • Powering Feature Stores with ClickHouse

    ClickHouse easyNovice

    Feature stores centralize the storage, versioning and retrieval of ML features so the same data serves both model training and inference. They typically combine a data source, an optional transformation engine, an offline training store with point-in-time correctness, and a low-latency online store. Physical stores like Tecton are integrated but inflexible, literal stores like Feast only store and serve features, and virtual stores like Featureform orchestrate pluggable components. ClickHouse fits best inside a virtual store, where it can act as data source, transformation engine via Materialized Views, and offline store, shown through a new Featureform integration.

  • Training Machine Learning Models with ClickHouse

    ClickHouse mediumAdept

    ClickHouse can serve as both the transformation engine and offline store in a virtual feature store, using the open-source Featureform as an orchestration layer. Exploration and feature engineering run as SQL at the data source, with no need to move data into frameworks like Spark, and results persist via INSERT INTO SELECT or views. A hands-on walkthrough deploys Featureform with ClickHouse in Docker, registers a Kaggle credit card fraud dataset, and defines versioned features. Those features are then used to train Logistic Regression and Decision Tree classifiers.

  • How HighLevel rebuilt its data platform for speed, scale, and simplicity on ClickHouse Cloud

    ClickHouse mediumAdept

    HighLevel replaced MySQL, Elasticsearch, Firestore and a document database with ClickHouse Cloud for lead activity, workflow logs, notifications and billing dashboards. Results: an 11 TB MySQL table compressed to 1.3 TB, P99 latency fell from over 6 s to under 200 ms, and a 60 TB Elasticsearch log store shrank to 6.27 TB served by three replicas. Notifications were modeled as MergeTree raw events plus ReplacingMergeTree read/delete state, with argMax instead of FINAL, Bloom filters and two-month partitions. Dashboards moved from daily cron reprocessing to SummingMergeTree materialized views. Key lessons are to model data as immutable, iterate on schemas, use bulk inserts, and instrument the client with per-service query observability.

  • Building a product analytics solution with ClickHouse

    ClickHouse mediumAdept

    ClickHouse's in-house product analytics platform, Galaxy, stores over 20 billion events (14 TB, roughly 14x compression) in a single denormalized MergeTree table keyed on created_at. A single sparse table avoids join overhead, since ClickHouse's sparse serialization makes empty columns cheap. Columns used for cohorts and filters should be top-level rather than buried in a JSON payload. Incremental materialized views speed up the few dozen recurring queries, and a custom SDK handles event capture.

  • Chaining Materialized Views in ClickHouse

    ClickHouse mediumAdept

    ClickHouse materialized views can be chained so that one view reads from a table populated by another, rather than having several views all read from the same Kafka engine table. Using the Wikimedia recent-changes stream, the walkthrough ingests raw events from Kafka into a MergeTree table and builds per-minute aggregation states (uniqState, sumState) in an AggregatingMergeTree. It then adds a 10-minute rollup view that reads those states with -MergeState combinators. The new view only picks up rows ingested after it is created, so older data has to be backfilled with an INSERT ... SELECT, and queries finish with -Merge combinators.

The quest for software engineering knowledge.

Look:
Layout: