What this thread does
Design a candidate MergeTree table around the queries and retention rule, then compare its pruning, storage and rollup results on representative data.
Do first: Run SELECT version(); and classify three representative queries by their leading equality/range filters and aggregation grain. Is the main workload tenant-and-time filtering, and does retention require deleting complete calendar months? Those answers choose the ordering and partitioning branches; keep a representative input sample for comparisons. Version function, schema-design workflow.
As of November 2026. All four branches target ClickHouse 26.10, announced November 6, 2026. The SQL below is an illustrative append-only events schema; adapt names, ranges and filters to your workload. Create candidates in a scratch database, not over an existing production table.
1. Most reads filter tenant first, then a time range
For ClickHouse 26.10, follow Choosing a primary key. Start with ORDER BY (tenant_id, event_time) for that access pattern; putting an unrelated unique event ID first would not match those filters. If most reads instead filter event type across all tenants, compare a second candidate ordered for that pattern. A MergeTree primary key is a sparse pruning index, not a uniqueness constraint.
CREATE TABLE events_candidate
(
tenant_id UInt32,
event_time DateTime64(3, 'UTC'),
event_type LowCardinality(String)
)
ENGINE = MergeTree
ORDER BY (tenant_id, event_time);
Load the same representative input into each candidate. Check with EXPLAIN indexes = 1 SELECT count() FROM events_candidate WHERE tenant_id = 7 AND event_time >= '2026-10-01 00:00:00' AND event_time < '2026-11-01 00:00:00' SETTINGS use_query_condition_cache = 0, use_skip_indexes_on_data_read = 0;. For ClickHouse 25.9+, the EXPLAIN reference requires these two query settings for meaningful index output. Compare selected granules/parts and the actual query's elapsed time; repeat for the other representative filters before choosing. EXPLAIN index details.
2. Retention follows whole months, or no such boundary exists
For ClickHouse 26.10, follow Choosing a partitioning key. If monthly expiry is the operational requirement, create a separate candidate with PARTITION BY toStartOfMonth(event_time) alongside the same ORDER BY. If there is no lifecycle requirement, start without explicit partitioning. Avoid partitioning by individual tenant or request ID just to accelerate a filter: parts merge only within a partition. Check: load multiple months, inspect the partition/part counts, and use the same EXPLAIN to compare date-bounded and cross-month queries. Reject a layout that creates many tiny parts. Partition choice and ordering choice solve different problems.
3. Inferred columns are all String, wide integers or Nullable
For ClickHouse 26.10, take the Selecting data types path. Inspect ranges, null semantics and distinct values before settling the candidate DDL. UInt32 above assumes tenant IDs fit and are nonnegative; DateTime64(3, 'UTC') assumes millisecond precision is needed. Try LowCardinality(String) for a small repeated vocabulary; retain String for unconstrained high-cardinality text. Keep Nullable when missing differs from a real default. Check: load boundary values and real missing values, compare query results, and inspect compressed/uncompressed column bytes on equal input. Never shrink a type solely because one sample happens to fit. The 26.10 release note also documents multi-column LowCardinality GROUP BY improvements; benchmark your query rather than assuming its example's gain.
4. A fixed daily aggregate is central to the workload
For ClickHouse 26.10, use the incremental materialized-view path, designing a target table and its query together:
CREATE TABLE daily_counts
(
tenant_id UInt32,
day Date,
n UInt64
)
ENGINE = SummingMergeTree
ORDER BY (tenant_id, day);
CREATE MATERIALIZED VIEW daily_counts_mv TO daily_counts AS
SELECT tenant_id, toDate(event_time) AS day, count() AS n
FROM events_candidate
GROUP BY tenant_id, day;
Create this before loading the candidate data. Read it with SELECT tenant_id, day, sum(n) FROM daily_counts GROUP BY tenant_id, day; background merges need not have combined every partial row. Check: insert two separate batches sharing the same tenant/day, compare the rollup with a raw count() grouped identically, and compare insert latency with and without the view. Existing rows are not automatically included; for a populated source use a coordinated backfill with a disjoint live/history boundary. Corrections or deletes to the source do not automatically retract old rollup contributions. Materialized-view semantics.
Evidence and limits
Robert Hodges and Mikhail Filimonov's February 18, 2026 Altinity report demonstrates the cost of bad partitioning and distinguishes tenant ordering from time partitioning. Stefan Kaeser's materialized-view benchmark, published December 5, 2022 and updated June 3, 2026, measures insert overhead as views add target writes. These are workload-specific measurements, not universal key orders or throughput predictions. This case assumes append-only analytical events; replacing/updating rows, distributed sharding and live schema cutovers need separate designs. The outcome is a candidate DDL plus evidence for its tradeoffs.
Not for: PostgreSQL/MySQL OLTP schemas, BigQuery or Snowflake table design; for Prisma/Postgres/Neon schema migration see case-database-schema-change-production-prisma-postgres-neon-locks. Not for: diagnosing one already-slow ClickHouse query, see clickhouse-make-slow-analytical-query-fast-cheaper; text-to-SQL answer correctness, see text-to-sql-wrong-answers-semantic-layer-or-model-the-schema-first; CDC pipeline selection, see postgres-to-warehouse-debezium-airbyte-fivetran-or-scripts; upsert deduplication or a general cluster-cost audit.
Started from a post by @ClickHouse, packaged by the editor. Original post