Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion migrations/clickhouse/versions/001_init_otel_spans_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
class InitOtelSpansTable(Migration):
"""Create the complete otel_spans table with all columns and indexes.
Supports both single-node (MergeTree) and cluster (ReplicatedMergeTree) setups.

Uses monthly partitioning (toYYYYMM) instead of daily because:
- Most queries scan time ranges (not specific days)
- Fewer partition files (12/year vs 365/year) = less overhead
- Better performance for team-level aggregations
- Still fast for specific day queries due to ORDER BY (OrgId, TeamId, Timestamp)
"""

version = "001"
Expand Down Expand Up @@ -88,7 +94,7 @@ def upgrade(self, client: clickhouse_connect.driver.Client, database: str) -> No
INDEX idx_experiment_id_minmax ExperimentId TYPE minmax GRANULARITY 4,
INDEX idx_run_id_minmax RunId TYPE minmax GRANULARITY 4
) ENGINE = {engine}
PARTITION BY toDate(Timestamp)
PARTITION BY toYYYYMM(Timestamp)
ORDER BY (OrgId, TeamId, Timestamp)
SETTINGS index_granularity = 8192
"""
Expand Down
Loading