Retail Marketing Analytics on ClickHouse: A Measured Case Study on 100 Million Ad Events

Retail marketing analytics stops being useful the moment the numbers arrive after the budget is spent. A campaign manager who learns at 9 a.m. that a paid social campaign overspent by midnight has a report, not a control loop. This case study builds the pipeline that closes that loop on ClickHouse, Apache Kafka and Debezium, and measures it.

The headline results from our retail marketing analytics lab build, on 100 million synthetic ad events:

  • A seven-day channel dashboard (impressions, clicks, spend, orders, revenue, ROAS, CPA) returned in a median of 63.6 ms from a five-minute rollup, against 310.9 ms from raw events.
  • A 30-day top-campaigns query returned in 46.1 ms from the rollup, against 796.7 ms from raw events.
  • The counter rollup occupied 35.48 MiB on disk against 1.25 GiB for the raw table, roughly 36 times smaller.
  • Our first rollup design was slower than the raw table: 1,196.8 ms against 605.1 ms. The reason, and the fix, take up the middle of this post.

Scope and method of this retail marketing analytics case study

This retail marketing analytics pipeline is a reference implementation built and measured in the ChistaDATA lab. It is not a client engagement, no customer data is involved, and the business figures in the query output (spend, revenue, ROAS) are artefacts of a synthetic generator. Only the engineering measurements are findings: sizes, row counts, latencies and index behaviour.

ItemLab value
EngineClickHouse 26.11.1.1, embedded through chDB 4.5.1 (single process, no replication)
Hardware2 vCPU, 7 GiB RAM, virtual disk
Ad events100,000,000 rows over 30 days, 500 campaigns, 6 channels, 20 million user IDs
Orders79,508 rows derived from clicks
Campaign skewPower-law: the largest campaign carries about 8 percent of spend
Timing methodEach query run 8 times, first run discarded, median of the remaining 7 reported with min and max; page cache warm
ConfigurationServer defaults except where the DDL below states a setting
Not run in the labKafka, Debezium, replication and tiered storage. Those statements are syntax-checked and marked as such

Two caveats before any number is quoted elsewhere. The generator produces hash-uniform values, so compression is pessimistic compared with production ad logs, which repeat far more. And two cores is a small machine; absolute latencies will fall on real hardware while the ratios between designs should hold more reliably. For production we target the current LTS line, ClickHouse 26.8 as of 1 December 2026, and every statement here should be re-tested there first.

What retail marketing analytics has to answer

A marketing operations team in retail works across paid search, paid social, display, retail media networks, email and affiliates. Each channel reports in its own console, on its own delay, with its own definition of a conversion. The team’s questions are simple to state and awkward to serve from a nightly warehouse load.

QuestionFreshness neededQuery shape
Is this campaign pacing ahead of its daily budget?MinutesOne campaign, last 24 hours, five-minute series
Which channel returns the most revenue per unit of spend this week?Minutes to an hourAll campaigns, 7 days, grouped by channel
Which ten campaigns consumed the most budget this month?HourlyAll campaigns, 30 days, top N
How many distinct shoppers did each channel reach?HourlyDistinct count over 7 to 30 days
Which click preceded each order within seven days?Daily, ad hocTime-ordered join of orders to clicks

The forcing constraint is the first row. Budget pacing needs spend that is at most a few minutes old, joined with orders from the transactional system, at a latency a dashboard can refresh against. Everything else in retail marketing analytics follows from serving that question without sacrificing the detail the last row needs.

Options we weighed for retail marketing analytics, and where ClickHouse is the wrong answer

Query the order database directly. For a retailer with a few million ad events a month, PostgreSQL with a well-chosen partitioning scheme and a handful of summary tables is enough for retail marketing analytics, and adding a second engine is cost without benefit. We would say so in a design review. The approach fails when event volume reaches hundreds of millions of rows and analytical scans start competing with checkout traffic for the same buffer pool.

Pre-aggregate in a stream processor only. Computing five-minute aggregates in Flink or Kafka Streams and storing only the results is cheap to serve. It is also brittle: every new dimension the marketing team asks for means a new job and a replay, and attribution questions that need raw click detail cannot be answered at all.

Batch into a cloud warehouse. This serves the weekly and monthly questions well. It does not serve pacing, because micro-batch loads at one-minute cadence are an expensive way to use an engine priced on scan volume or slot time.

Raw events plus incremental rollups in ClickHouse. This is the retail marketing analytics design we built. Raw detail stays queryable for attribution, AggregatingMergeTree rollups maintained by materialized views serve the dashboards, and a new dimension is a new view plus a backfill from raw. The cost is operational: a ClickHouse cluster, Keeper, and a Kafka estate to run.

Reference architecture for retail marketing analytics

Retail marketing analytics reference architecture on ClickHouse with Apache Kafka, Debezium, materialized views and rollup tables

Figure 1. Retail marketing analytics reference architecture: ad and storefront events arrive through Kafka, orders arrive through Debezium change data capture, and ClickHouse materialized views maintain the rollups that dashboards read.

Ad platform exports, retail media feeds and storefront events are published to a Kafka topic. Orders are captured from the transactional database with Debezium, so the order system is never queried by an analyst. ClickHouse consumes both topics, stores raw detail in MergeTree tables, and maintains rollups at insert time. Dashboards read the rollups; attribution work reads raw.

The storefront stamps each order with the campaign from the shopper’s last tracked click (UTM parameters held in the session). That gives last-touch attribution at write time, which is what the live dashboards use. Other attribution windows are computed on demand from raw events, shown later.

Raw event schema and sort key

The sort key decides what is cheap. Retail marketing analytics queries almost always filter by channel and campaign and then by time, so the key leads with the low-cardinality columns and ends with the timestamp.

-- Retail marketing analytics: raw event and order tables
CREATE DATABASE IF NOT EXISTS mkt;

CREATE TABLE mkt.ad_events
(
    event_time    DateTime                CODEC(Delta(4), ZSTD(1)),
    event_type    Enum8('impression' = 1, 'click' = 2),
    channel       LowCardinality(String),
    campaign_id   UInt32,
    ad_group_id   UInt32,
    creative_id   UInt32,
    region        LowCardinality(String),
    device        LowCardinality(String),
    user_id       UInt64                  CODEC(ZSTD(1)),
    cost_micros   UInt64                  CODEC(T64, ZSTD(1))
)
ENGINE = MergeTree
PARTITION BY toYYYYMM(event_time)
ORDER BY (channel, campaign_id, event_time)
SETTINGS index_granularity = 8192;

CREATE TABLE mkt.orders
(
    order_time    DateTime                CODEC(Delta(4), ZSTD(1)),
    order_id      UInt64,
    user_id       UInt64                  CODEC(ZSTD(1)),
    channel       LowCardinality(String),
    campaign_id   UInt32,
    revenue_cents UInt64                  CODEC(T64, ZSTD(1))
)
ENGINE = MergeTree
PARTITION BY toYYYYMM(order_time)
ORDER BY (user_id, order_time)
SETTINGS index_granularity = 8192;

Money is stored as integers (micros for cost, cents for revenue) so that sums in the rollups are exact. The orders table is sorted by shopper and time because its main raw consumer is the attribution join. On a replicated cluster the engine line becomes ReplicatedMergeTree('/clickhouse/tables/{shard}/mkt/ad_events', '{replica}'); nothing else in the definition changes.

After loading 100 million events, system.parts reported 1.25 GiB compressed from 3.35 GiB uncompressed, a ratio of 2.68 and 13.45 bytes per row. system.columns shows where the bytes go: user_id took 333.52 MiB and the two creative hierarchy columns about 530 MiB between them, while campaign_id and channel, which lead the sort key, compressed more than 200 to 1 and together cost about 2 MiB.

The pacing query needs no rollup

The single-campaign pacing query is the one with the tightest freshness requirement, and the sort key already serves it from raw data:

-- Retail marketing analytics: budget pacing for one campaign
SELECT
    toStartOfFiveMinutes(event_time)              AS bucket,
    round(sum(cost_micros) / 1e6, 2)              AS spend,
    countIf(event_type = 'click')                 AS clicks
FROM mkt.ad_events
WHERE channel = 'paid_search'
  AND campaign_id = 6
  AND event_time >= toDateTime('2026-11-30 00:00:00', 'UTC')
  AND event_time <  toDateTime('2026-12-01 00:00:00', 'UTC')
GROUP BY bucket
ORDER BY bucket;

EXPLAIN indexes = 1 for this statement, trimmed to the primary key section:

ReadFromMergeTree (mkt.ad_events)
  Indexes:
    ...
    PrimaryKey
      Keys:
        channel
        campaign_id
        event_time
      Parts: 2/2
      Granules: 7/12208
      Search Algorithm: binary search

Seven granules of 12,208 are read, and the median latency was 8.1 ms (min 7.0, max 32.9). A dashboard panel that watches one campaign can read raw events and see data as soon as the insert lands. This matters for the design: the rollups exist for the wide questions, not for pacing.

Ingestion from Kafka

The lab loaded data with INSERT ... SELECT. In a production retail marketing analytics deployment the same tables are fed by the Kafka table engine and a materialized view. The statements below were syntax-checked but not executed in the lab, and broker credentials belong in the server’s kafka configuration section, never in DDL.

-- Retail marketing analytics: Kafka ingestion (syntax-checked, not run in the lab)
CREATE TABLE mkt.kafka_ad_events
(
    event_time    DateTime,
    event_type    String,
    channel       String,
    campaign_id   UInt32,
    ad_group_id   UInt32,
    creative_id   UInt32,
    region        String,
    device        String,
    user_id       UInt64,
    cost_micros   UInt64
)
ENGINE = Kafka
SETTINGS
    kafka_broker_list = 'kafka-1:9092,kafka-2:9092,kafka-3:9092',
    kafka_topic_list = 'ad_events',
    kafka_group_name = 'clickhouse_ad_events',
    kafka_format = 'JSONEachRow',
    kafka_num_consumers = 4,
    kafka_max_block_size = 1048576,
    kafka_handle_error_mode = 'stream';

CREATE MATERIALIZED VIEW mkt.mv_kafka_to_ad_events
TO mkt.ad_events
AS
SELECT
    event_time,
    CAST(event_type, 'Enum8(\'impression\' = 1, \'click\' = 2)') AS event_type,
    channel,
    campaign_id,
    ad_group_id,
    creative_id,
    region,
    device,
    user_id,
    cost_micros
FROM mkt.kafka_ad_events
WHERE length(_error) = 0;

Two points deserve attention. With kafka_handle_error_mode = 'stream', malformed messages surface in the _error and _raw_message virtual columns instead of stalling the consumer; route them to a dead-letter table with a second view. And the Kafka engine gives at-least-once delivery. A consumer rebalance can replay a batch, and replayed rows inflate additive counters. We come back to this under hardening.

For reference, the lab’s single-statement load ran at about 455,000 rows per second on two cores (100 million rows in 219.7 s), with row generation and two materialized views inside the same pipeline. Treat it as a floor for sizing rather than a benchmark of Kafka ingestion.

The hard problem: reach does not belong in a five-minute rollup

Our first retail marketing analytics rollup put every metric in one AggregatingMergeTree table: additive counters as SimpleAggregateFunction(sum, UInt64) columns and reach as an AggregateFunction(uniqCombined64(14), UInt64) state, one row per campaign per five minutes. It is the obvious layout and it measured badly.

The combined rollup held 4,323,740 rows in 772.93 MiB, or 187.45 bytes per row, almost all of it sketch state. The seven-day channel query took a median of 1,196.8 ms against it. The same question asked of the raw table, with the distinct count computed directly, took 605.1 ms. A rollup that is slower than the data it summarises is not a rollup.

The mechanism is straightforward once measured. Distinct counts are not additive, so every read has to deserialise and merge one state per campaign per bucket: 2,016 states per campaign for seven days. At five-minute grain most states hold a few dozen user IDs or fewer, so the table pays per-row state overhead without getting any reduction in return. And because the counters share rows with the states, even queries that never touch reach live in a table whose parts are dominated by them.

Rollup redesign for retail marketing analytics on ClickHouse: one combined rollup compared with separate counter and reach rollups

Figure 2. Retail marketing analytics rollup redesign. Splitting additive counters from distinct-count states cut the seven-day dashboard from 1,196.8 ms to 63.6 ms in our lab.

The final design separates the two. Counters stay at five-minute grain, where they are cheap. Reach moves to a daily table, because nobody reads reach by the minute and a daily state per campaign actually aggregates something.

-- Retail marketing analytics: counter and reach rollup tables
CREATE TABLE mkt.campaign_metrics_5m
(
    bucket        DateTime                CODEC(Delta(4), ZSTD(1)),
    channel       LowCardinality(String),
    campaign_id   UInt32,
    impressions   SimpleAggregateFunction(sum, UInt64),
    clicks        SimpleAggregateFunction(sum, UInt64),
    spend_micros  SimpleAggregateFunction(sum, UInt64),
    orders        SimpleAggregateFunction(sum, UInt64),
    revenue_cents SimpleAggregateFunction(sum, UInt64)
)
ENGINE = AggregatingMergeTree
PARTITION BY toYYYYMM(bucket)
ORDER BY (channel, campaign_id, bucket)
SETTINGS index_granularity = 8192;

CREATE TABLE mkt.campaign_reach_1d
(
    day           Date,
    channel       LowCardinality(String),
    campaign_id   UInt32,
    reach         AggregateFunction(uniqCombined64(14), UInt64)
)
ENGINE = AggregatingMergeTree
PARTITION BY toYYYYMM(day)
ORDER BY (channel, campaign_id, day)
SETTINGS index_granularity = 8192;

Three materialized views feed them. Two write into the same counter table, one from ad events and one from orders, each supplying zeros for the columns it does not own. AggregatingMergeTree sums them at merge time, so spend and revenue for a campaign meet in one row without a join.

Retail marketing analytics materialized views on ClickHouse writing spend and revenue into one AggregatingMergeTree rollup row

Figure 3. Two views, one row in the retail marketing analytics rollup: ad spend and order revenue for the same campaign and bucket are summed by the engine, so the dashboard query needs no join. Row values in the figure are illustrative.

-- Retail marketing analytics: materialized views feeding the rollups
CREATE MATERIALIZED VIEW mkt.mv_ad_events_to_metrics_5m
TO mkt.campaign_metrics_5m
AS
SELECT
    toStartOfFiveMinutes(event_time)            AS bucket,
    channel,
    campaign_id,
    countIf(event_type = 'impression')          AS impressions,
    countIf(event_type = 'click')               AS clicks,
    sum(cost_micros)                            AS spend_micros,
    toUInt64(0)                                 AS orders,
    toUInt64(0)                                 AS revenue_cents
FROM mkt.ad_events
GROUP BY
    bucket,
    channel,
    campaign_id;

CREATE MATERIALIZED VIEW mkt.mv_orders_to_metrics_5m
TO mkt.campaign_metrics_5m
AS
SELECT
    toStartOfFiveMinutes(order_time)            AS bucket,
    channel,
    campaign_id,
    toUInt64(0)                                 AS impressions,
    toUInt64(0)                                 AS clicks,
    toUInt64(0)                                 AS spend_micros,
    count()                                     AS orders,
    sum(revenue_cents)                          AS revenue_cents
FROM mkt.orders
GROUP BY
    bucket,
    channel,
    campaign_id;

CREATE MATERIALIZED VIEW mkt.mv_ad_events_to_reach_1d
TO mkt.campaign_reach_1d
AS
SELECT
    toDate(event_time)                          AS day,
    channel,
    campaign_id,
    uniqCombined64State(14)(user_id)            AS reach
FROM mkt.ad_events
GROUP BY
    day,
    channel,
    campaign_id;

After the split, the counter table held the same 4,323,740 rows in 35.48 MiB (8.6 bytes per row). The reach table held 15,500 rows in 101.85 MiB. Reach merged from daily states differed from the direct computation on raw events by at most 0.76 percent on any channel; uniqCombined64 is an approximation in both cases, so agree the tolerance with the marketing team before the number appears on a slide.

The queries behind retail marketing analytics dashboards

The channel dashboard reads only the counter rollup. Aggregates are always re-summed at read time, because background merges are asynchronous and a bucket may still be spread across parts.

-- Retail marketing analytics: seven-day channel dashboard
SELECT
    channel,
    sum(impressions)                              AS impressions,
    sum(clicks)                                   AS clicks,
    round(100 * clicks / impressions, 2)          AS ctr_pct,
    round(sum(spend_micros) / 1e6, 2)             AS spend,
    sum(orders)                                   AS orders,
    round(sum(revenue_cents) / 100, 2)            AS revenue,
    round(revenue / spend, 2)                     AS roas,
    round(spend / orders, 2)                      AS cpa
FROM mkt.campaign_metrics_5m
WHERE bucket >= toDateTime('2026-11-24 00:00:00', 'UTC')
  AND bucket <  toDateTime('2026-12-01 00:00:00', 'UTC')
GROUP BY channel
ORDER BY spend DESC;

Output from the lab (synthetic values; three of six rows shown):

┌─channel──────┬─impressions─┬─clicks─┬─ctr_pct─┬─────spend─┬─orders─┬───revenue─┬─roas─┬───cpa─┐
│ paid_social  │     5179428 │ 111119 │    2.15 │ 126572.22 │   4278 │ 534510.72 │ 4.22 │ 29.59 │
│ display      │     3837327 │  82266 │    2.14 │  93886.37 │   3110 │ 391381.43 │ 4.17 │ 30.19 │
│ retail_media │     3609963 │  77587 │    2.15 │  88439.86 │   2950 │ 370868.84 │ 4.19 │ 29.98 │
...

An honest note on the plan: bucket is the last key column, so a time-only filter cannot prune by primary key. EXPLAIN indexes = 1 showed all 529 granules read. The query is fast because the table is small, not because the index is selective. At a few thousand campaigns and a year of retention that stops being comfortable, and the next step is an hourly or daily rollup cascaded from this one.

Reach comes from the daily table with the -Merge combinator:

-- Retail marketing analytics: seven-day reach by channel
SELECT
    channel,
    uniqCombined64Merge(14)(reach)                AS reach
FROM mkt.campaign_reach_1d
WHERE day >= toDate('2026-11-24')
  AND day <  toDate('2026-12-01')
GROUP BY channel
ORDER BY reach DESC;

Attribution windows on raw events with ASOF JOIN

Last-touch attribution stamped by the storefront is good enough for live dashboards. When the team wants to test a different rule, raw detail answers it. This statement finds, for every order, the most recent click by the same shopper at or before the order time, and keeps the pairs within seven days:

-- Retail marketing analytics: seven-day click-to-order attribution
SELECT
    c.channel                                     AS channel,
    count()                                       AS attributed_orders,
    round(sum(o.revenue_cents) / 100, 2)          AS attributed_revenue,
    round(avg(o.order_time - c.event_time) / 3600, 1) AS avg_hours_to_order
FROM mkt.orders AS o
ASOF INNER JOIN
(
    SELECT
        user_id,
        event_time,
        channel
    FROM mkt.ad_events
    WHERE event_type = 'click'
) AS c
    ON  o.user_id = c.user_id
    AND o.order_time >= c.event_time
WHERE o.order_time - c.event_time <= 7 * 86400
GROUP BY channel
ORDER BY attributed_revenue DESC;

Joining 79,508 orders to roughly 2.1 million clicks took a median of 1,736.6 ms (min 1,695.3, max 1,928.2). That is acceptable for an analyst and wrong for a dashboard tile. The right-hand side is built in memory, so on production volumes restrict the click subquery to the attribution window and watch memory_usage for the statement in system.query_log before scheduling it.

Measured results for the retail marketing analytics workload

Measured query latency for retail marketing analytics on ClickHouse comparing raw events with rollup tables

Figure 4. Retail marketing analytics query latency in the lab, raw events against rollups. Medians of seven warm runs on 2 vCPU.

QueryRaw events, median ms (min to max)Rollup, median ms (min to max)Ratio
30-day top 10 campaigns by spend796.7 (784.7 to 903.4)46.1 (44.1 to 69.9)17.3x
7-day reach by channel605.1 (548.4 to 638.3)219.7 (204.4 to 291.8)2.8x
7-day channel dashboard, counters310.9 (290.6 to 325.3)63.6 (56.6 to 121.3)4.9x
24-hour pacing, one campaign8.1 (7.0 to 32.9)6.2 (5.5 to 38.9)1.3x
First design: 7-day dashboard with reach in one rollup605.1 (548.4 to 638.3)1,196.8 (1,140.1 to 1,314.3)0.5x

Read the table for its shape. Wide scans over many campaigns gain most from the counter rollup. Distinct counts gain less, because merging sketches is real work at any grain. Selective queries on the leading sort-key columns gain almost nothing, and can stay on raw data where they are freshest. The raw reach figure includes the counters in the same pass, so the 2.8x understates the reach-only gain slightly.

Backfilling the rollups from raw is cheap enough to make schema evolution routine. Rebuilding the counter rollup for all 100 million events took 7.2 s and the reach rollup 3.9 s with plain INSERT ... SELECT ... GROUP BY statements. Adding a dimension such as region to the retail marketing analytics dashboards is therefore a new table, a new view and a backfill, not a pipeline rewrite.

Production hardening for retail marketing analytics

None of the following was exercised in the lab. These are the items we would put in the design document before a retail marketing analytics pipeline carries a real budget, each with the system table that verifies it. The statements were syntax-checked only.

Duplicates and order changes

Additive rollups have no defence against replayed rows. Two controls are worth their cost. First, reconcile closed windows: once an hour, compare the previous day’s rollup totals with the same totals from raw, and alert on any difference. Second, if replays are frequent, move ingestion to a Kafka Connect sink with exactly-once delivery in place of the Kafka table engine.

Orders are harder, because Debezium emits updates as well as inserts: refunds, cancellations, amended baskets. The lab models orders as insert-only. In production, land the change stream in a ReplacingMergeTree keyed on order_id with a version column, and feed the rollup with signed revenue deltas, or accept that revenue for the trailing few days is rebuilt nightly from the deduplicated table.

Replication, Keeper and retention

Run at least two replicas per shard with a three-node ClickHouse Keeper ensemble on separate hosts. Most retail marketing analytics estates fit one shard for a long time; the rollups are small and raw events compress well, so add shards for ingest throughput, not out of habit. Check system.replicas for absolute_delay and queue_size before trusting any dashboard during an incident.

Raw events lose value quickly, while rollups stay useful for year-over-year comparison. Moving older raw parts to object storage is non-destructive and reversible:

-- Retail marketing analytics: tiered storage for raw events
-- Requires a storage policy with a volume named 'cold'; validate on staging first.
-- Before: confirm the policy.
SELECT policy_name, volume_name, disks
FROM system.storage_policies
WHERE policy_name = 'hot_cold';

ALTER TABLE mkt.ad_events
    MODIFY TTL event_time + INTERVAL 90 DAY TO VOLUME 'cold';

-- After: confirm where the parts live.
SELECT disk_name, count() AS parts, formatReadableSize(sum(bytes_on_disk)) AS size
FROM system.parts
WHERE database = 'mkt' AND table = 'ad_events' AND active
GROUP BY disk_name;

We have deliberately not shown a TTL ... DELETE clause. Deleting raw events removes the ability to backfill and re-attribute, and it needs a written retention decision from the business and a verified backup, not a line copied from a blog post.

What to watch

-- Retail marketing analytics: monitoring queries
-- Dashboard latency against the rollup, p95 and p99 per five minutes.
SELECT
    toStartOfFiveMinutes(event_time)              AS bucket,
    count()                                       AS queries,
    quantile(0.95)(query_duration_ms)             AS p95_ms,
    quantile(0.99)(query_duration_ms)             AS p99_ms
FROM system.query_log
WHERE type = 'QueryFinish'
  AND event_date = today()
  AND has(tables, 'mkt.campaign_metrics_5m')
GROUP BY bucket
ORDER BY bucket;

-- Part count per partition: a rising number means merges are behind inserts.
SELECT
    table,
    partition,
    count()                                       AS active_parts
FROM system.parts
WHERE database = 'mkt' AND active
GROUP BY table, partition
ORDER BY active_parts DESC
LIMIT 10;

Add system.kafka_consumers for consumer exceptions and assignment state, and export Kafka consumer-group lag to the same Prometheus and Grafana stack that serves the retail marketing analytics dashboards. Freshness is the product here, so lag on the ad_events topic deserves an SLO of its own.

What we would do differently, and what this does not prove

  • We would start with separate counter and reach tables. The combined rollup cost a load and a round of measurement to rule out, and the measurement was the useful part.
  • Five-minute grain was chosen for the lab’s cardinality. At production event rates a one-minute counter rollup is reasonable, with an hourly rollup cascaded from it for long ranges.
  • Region and device are in the raw table but not in the rollups. Each added dimension multiplies rollup rows; measure before adding more than one.
  • The lab is a single embedded process. It says nothing about replication lag, Keeper behaviour, concurrent dashboard users or Kafka throughput.
  • Synthetic uniform data understates compression and may flatter or penalise particular queries. Rerun the DDL and queries above on a sample of your own retail marketing analytics events before sizing hardware.

Frequently asked questions

How fresh is the data in this retail marketing analytics design?

Materialized views run inside the insert, so a rollup row is queryable as soon as the block that produced it commits. End-to-end freshness is therefore set by the Kafka consumer’s flush interval and block size, typically a few seconds, plus whatever delay the ad platforms impose on their own exports.

Do we need Kafka for retail marketing analytics on ClickHouse?

Not always. If the only sources are a few hourly platform exports, batch inserts from object storage are simpler and cheaper to operate. Kafka earns its place when storefront events and order changes must arrive continuously, or when several consumers need the same stream.

Can retail marketing analytics rollups serve finance reporting?

Use them for operational decisions and reconcile against the ledger for anything that is booked. Approximate reach, at-least-once delivery and late order amendments are acceptable for steering a campaign and are not acceptable for a revenue statement.

Where this leaves a marketing operations team

The measured outcome is a retail marketing analytics pipeline in which pacing reads raw events in single-digit milliseconds, channel and campaign dashboards read a 35 MiB rollup in tens of milliseconds, and attribution questions still have every click available. The design decision that mattered most was unglamorous: keep additive counters and distinct-count sketches in different tables at different grains.

If you are planning retail marketing analytics on ClickHouse, or have a rollup that has become slower than the table underneath it, our ClickHouse consulting team reviews schema, materialized-view topology and ingestion design against your own workload, and our ClickHouse support engineers run these systems 24×7. As with everything on this blog: test before applying to production, and maintain a robust disaster recovery posture.

About ChistaDATA Inc. 274 Articles
ChistaDATA is a full-stack ClickHouse infrastructure operations company delivering consulting, 24×7 enterprise support, and managed services, with core expertise in performance engineering, scalability, and data SRE. Headquartered in California, our consulting and support engineering teams operate from San Francisco, Vancouver, London, Germany, Russia, Ukraine, Australia, Singapore, and India, providing follow-the-sun, enterprise-class consultative support around the clock. We work closely with more than 200 customers globally, including some of the largest planet-scale internet properties, financial-services institutions, consumer brands, and industrial IoT programmes.