1. Core engine
MergeTree is ClickHouse's primary engine for analytics tables.
ENGINE = MergeTreeTyporithm · easy
Step 1 of 8 · intro card
Columns & Engines
Create a MergeTree table: ORDER BY defines the on-disk sort and sparse index, PARTITION BY groups rows into monthly parts.
MergeTree is ClickHouse's primary engine, storing data column by column in sorted, immutable parts.
ORDER BY sets how rows are physically sorted and builds the sparse primary index used to skip data.
PARTITION BY splits data into parts, often by month, so queries and TTL can prune whole partitions.
ENGINE = MergeTree for analytics.
ORDER BY = sort order + sparse index.
PARTITION BY groups rows into parts.
CREATE TABLE events
(
event_date Date,
user_id UInt64,
event_type LowCardinality(String),
value Float64
)
ENGINE = MergeTree
PARTITION BY toYYYYMM(event_date)
ORDER BY (user_id, event_date);Connect each part of the code to the concept before you type.
MergeTree is ClickHouse's primary engine for analytics tables.
ENGINE = MergeTreeORDER BY sets the on-disk sort order and builds the sparse primary index.
ORDER BY (user_id, event_date)Rows are grouped into parts per month for pruning and TTL.
PARTITION BY toYYYYMM(event_date)LowCardinality dictionary-encodes columns with few distinct values.
LowCardinality(String)Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.