Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
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.
-- ✅ GOOD: Use indexed columns firstSELECT*FROM markets_analytics
WHEREdate>='2025-01-01'AND market_id ='market-123'AND volume >1000ORDERBYdateDESC
LIMIT 100;
-- ❌ BAD: Filter on non-indexed columns firstSELECT*FROM markets_analytics
WHERE volume >1000AND market_name LIKE'%election%'ANDdate>='2025-01-01';
Aggregations
-- ✅ GOOD: Use ClickHouse-specific aggregation functionsSELECT
toStartOfDay(created_at) ASday,
market_id,
sum(volume) AS total_volume,
count() AS total_trades,
uniq(trader_id) AS unique_traders,
avg(trade_size) AS avg_size
FROM trades
WHERE created_at >= today() -INTERVAL7DAYGROUPBYday, market_id
ORDERBYdayDESC, total_volume DESC;
-- ✅ Use quantile for percentiles (more efficient than percentile)SELECT
quantile(0.50)(trade_size) AS median,
quantile(0.95)(trade_size) AS p95,
quantile(0.99)(trade_size) AS p99
FROM trades
WHERE created_at >= now() -INTERVAL1HOUR;
Window Functions
-- Calculate running totalsSELECTdate,
market_id,
volume,
sum(volume) OVER (
PARTITIONBY market_id
ORDERBYdateROWSBETWEEN UNBOUNDED PRECEDING ANDCURRENTROW
) AS cumulative_volume
FROM markets_analytics
WHEREdate>= today() -INTERVAL30DAYORDERBY market_id, date;