Back to Langfuse

Consider Starting Without Partitioning

.agents/skills/clickhouse-best-practices/rules/schema-partition-start-without.md

3.172.11.0 KB
Original Source

Consider Starting Without Partitioning

Impact: MEDIUM

Start without partitioning and add it later only if:

  • You have clear data lifecycle requirements (retention, archiving)
  • Your access patterns clearly benefit from partition pruning
  • You understand the cardinality implications

Example (start simple):

sql
-- Start simple, no partitioning
CREATE TABLE events (
    timestamp DateTime,
    event_type LowCardinality(String),
    user_id UInt64
)
ENGINE = MergeTree()
ORDER BY (event_type, timestamp);

-- Add partitioning later if needed for lifecycle management
-- (requires table recreation or materialized view migration)

When to add partitioning:

NeedAdd Partitioning?
Time-based data retentionYes
Archive old data to cold storageYes
Query performance on time rangesMaybe (test first)
No specific lifecycle needsNo

Reference: Choosing a Partitioning Key