---
title: "Modeling Machine Learning Data in OLAP databases"
description: "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."
url: "https://swe.quest/articles/modeling-machine-learning-data-in-olap-databases-0fad2c579add8f45"
canonical: "https://clickhouse.com/blog/modeling-machine-learning-data-in-clickhouse"
source: "ClickHouse"
published: "2024-08-08"
difficulty: "medium"
kind: "How-to"
reading_minutes: 26
tags: ["ml-platform","analytics","sql","data-pipelines"]
---

# Modeling Machine Learning Data in OLAP databases

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2024-08-08, 26 min read, How-to. Original: [https://clickhouse.com/blog/modeling-machine-learning-data-in-clickhouse](https://clickhouse.com/blog/modeling-machine-learning-data-in-clickhouse)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [ML platforms](https://swe.quest/tags/ml-platform.md) (AI & ML)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [SQL](https://swe.quest/tags/sql.md) (Languages)
- [Data pipelines](https://swe.quest/tags/data-pipelines.md) (Data & databases)

## Prerequisites

- SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- feature store concepts ([easy posts on ML platforms](https://swe.quest/tags/ml-platform.md?difficulty=easy))
- ClickHouse MergeTree basics ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))

## Keywords

ClickHouse, ReplacingMergeTree, ASOF JOIN, materialized views, chDB, feature store

## Related posts

- [Powering Feature Stores with ClickHouse](https://swe.quest/articles/powering-feature-stores-with-clickhouse-9d4db3ca1ba6f6e2.md): ClickHouse · 2024-01-18 · Easy · 17 min read · ML platforms, Analytics & OLAP, Machine learning
  Feature stores centralize the storage, versioning and retrieval of ML features so the same data serves both model training and inference.
- [Training Machine Learning Models with ClickHouse](https://swe.quest/articles/training-machine-learning-models-with-clickhouse-fff12f2958d1827c.md): ClickHouse · 2024-04-03 · Medium · 25 min read · ML platforms, Analytics & OLAP, Machine learning, Python
  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.
- [How HighLevel rebuilt its data platform for speed, scale, and simplicity on ClickHouse Cloud](https://swe.quest/articles/how-highlevel-rebuilt-its-data-platform-for-speed-scale-and-simplicity-on-826417013669e8fd.md): ClickHouse · 2026-01-12 · Medium · 8 min read · Analytics & OLAP, Databases, Scaling, Observability
  HighLevel replaced MySQL, Elasticsearch, Firestore and a document database with ClickHouse Cloud for lead activity, workflow logs, notifications and billing dashboards.
- [Building a product analytics solution with ClickHouse](https://swe.quest/articles/building-a-product-analytics-solution-with-clickhouse-786424348993d92f.md): ClickHouse · 2024-12-05 · Medium · 24 min read · Analytics & OLAP, SQL, Databases, Product engineering
  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.
- [Chaining Materialized Views in ClickHouse](https://swe.quest/articles/chaining-materialized-views-in-clickhouse-79c630686e93ebe9.md): ClickHouse · 2024-04-16 · Medium · 8 min read · Analytics & OLAP, Stream processing, SQL
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
