← ClaudeAtlas

clickhouse-iolisted

ClickHouse (OLAP / column-oriented) patterns for high-performance analytics and data engineering. Use this skill whenever designing ClickHouse tables and engines (MergeTree family), writing or optimizing analytical queries, modeling partitioning and ordering keys, setting up materialized views, or ingesting large datasets for real-time analytics.
sardonyx0827/dotfiles · ★ 0 · Data & Documents · score 72
Install: claude install-skill sardonyx0827/dotfiles
# ClickHouse Analytics Patterns ClickHouse-specific patterns for high-performance analytics and data engineering. ## Overview ClickHouse is a column-oriented database management system (DBMS) for online analytical processing (OLAP). It's optimized for fast analytical queries on large datasets. **Key Features:** - Column-oriented storage - Data compression - Parallel query execution - Distributed queries - Real-time analytics ## Table Design Patterns ### MergeTree Engine (Most Common) ```sql CREATE TABLE products_analytics ( date Date, product_id String, product_name String, sales UInt64, orders UInt32, unique_buyers UInt32, avg_order_size Float64, created_at DateTime ) ENGINE = MergeTree() PARTITION BY toYYYYMM(date) ORDER BY (date, product_id) SETTINGS index_granularity = 8192; ``` ### ReplacingMergeTree (Deduplication) ```sql -- For data that may have duplicates (e.g., from multiple sources) CREATE TABLE user_events ( event_id String, user_id String, event_type String, timestamp DateTime, properties String ) ENGINE = ReplacingMergeTree() PARTITION BY toYYYYMM(timestamp) ORDER BY (user_id, event_id, timestamp) PRIMARY KEY (user_id, event_id); ``` ### AggregatingMergeTree (Pre-aggregation) ```sql -- For maintaining aggregated metrics CREATE TABLE product_stats_hourly ( hour DateTime, product_id String, total_sales AggregateFunction(sum, UInt64), total_orders AggregateFunction(count, UInt32), u