fix: set deduplicate_merge_projection_mode for ReplacingMergeTree projection
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m8s
CI / docker (push) Successful in 42s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 37s

ClickHouse 24.12 requires this setting before adding projections to
ReplacingMergeTree tables. Using 'drop' mode which discards the projection
during deduplication merges and rebuilds it afterward.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-03 15:14:56 +02:00
parent 984bb2d40f
commit bb3e1e2bc3

View File

@@ -1,6 +1,9 @@
-- Projection for fast route_id + instance_id lookups on route_diagrams. -- Projection for fast route_id + instance_id lookups on route_diagrams.
-- The primary key is (tenant_id, content_hash) which serves hash-based lookups. -- The primary key is (tenant_id, content_hash) which serves hash-based lookups.
-- Queries filtering by route_id + instance_id were scanning millions of rows. -- Queries filtering by route_id + instance_id were scanning millions of rows.
-- ReplacingMergeTree requires deduplicate_merge_projection_mode to be set (ClickHouse 24.12+).
ALTER TABLE route_diagrams MODIFY SETTING deduplicate_merge_projection_mode = 'drop';
ALTER TABLE route_diagrams ALTER TABLE route_diagrams
ADD PROJECTION IF NOT EXISTS prj_route_instance ADD PROJECTION IF NOT EXISTS prj_route_instance
(SELECT content_hash, created_at ORDER BY tenant_id, route_id, instance_id, created_at); (SELECT content_hash, created_at ORDER BY tenant_id, route_id, instance_id, created_at);