clickhouse
БесплатноБез исполняемых скриптовНе проверенClickHouse is a columnar OLAP database for real-time analytical queries over billions of rows. It speaks SQL, stores data in MergeTree tables, and rolls up…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
ClickHouse
Overview
ClickHouse is a column-oriented database for online analytical processing: it scans and aggregates very large tables quickly through columnar storage, vectorized execution and compression. It is a poor fit for frequent single-row updates or deletes and for transactional workloads; keep those in PostgreSQL or MySQL and send analytical copies to ClickHouse. New feature releases come monthly (26.10 at the time of writing), with some versions designated long-term support; pin a version tag in production instead of latest.
Instructions
Run it with Docker
The image's default user cannot be used from outside the container without a password, so create a user at startup. Publish ports on loopback only unless you have put TLS and a firewall in front.
export CLICKHOUSE_PASSWORD="$(openssl rand -hex 16)"
docker run -d --name clickhouse-server \
-p 127.0.0.1:8123:8123 -p 127.0.0.1:9000:9000 \
-e CLICKHOUSE_USER=analytics -e CLICKHOUSE_PASSWORD="$CLICKHOUSE_PASSWORD" \
--ulimit nofile=262144:262144 \
-v clickhouse-data:/var/lib/clickhouse \
clickhouse/clickhouse-server:26.10
docker exec -it clickhouse-server clickhouse-client -u analytics --password "$CLICKHOUSE_PASSWORD"
curl -s -u "analytics:$CLICKHOUSE_PASSWORD" http://127.0.0.1:8123/ --data-binary 'SELECT version()'
Without credentials the HTTP call returns Code: 194 ... Authentication failed (REQUIRED_PASSWORD).
Design MergeTree tables
ENGINE = MergeTreeis the default choice.ORDER BYis the sorting and sparse primary key: put columns you filter on most first, low-cardinality ones before high-cardinality ones. Queries that filter on a prefix of it skip whole granules.PARTITION BY toYYYYMM(created_at)is for data lifecycle (dropping or moving old months), not for speed. Keep partitions to tens or hundreds, never thousands.- Use
LowCardinality(String)for columns with fewer than roughly 10,000 distinct values, and the narrowest numeric and date types that fit. - Insert in batches of thousands of rows at a time or more. Many tiny inserts create many parts and slow everything down.
ReplacingMergeTree(version)removes duplicates only during background merges, so read withFINAL(orargMax) when you need the latest row now.
Rollups with materialized views
A materialized view runs on every insert into its source table and writes into a target table. Rolling up distinct counts needs aggregate states, because summing uniq results from different inserts double counts users. Use AggregatingMergeTree with uniqState on write and uniqMerge on read. SummingMergeTree is only correct for plain additive numbers. A view does not backfill rows inserted before it was created.
Query from Node.js
npm install @clickhouse/client (the official client; uses the HTTP interface on port 8123). Pass values as typed query parameters ({days:UInt32}), never by string interpolation, and read credentials from the environment.
Examples
Example 1: Event table, batch load and daily active users
User request: "Track page views and signups, and show me daily active users for the last 30 days"
CREATE TABLE events (
event_id UUID DEFAULT generateUUIDv4(),
user_id UInt64,
event_name LowCardinality(String),
properties String,
created_at DateTime DEFAULT now()
) ENGINE = MergeTree
PARTITION BY toYYYYMM(created_at)
ORDER BY (event_name, toStartOfHour(created_at), user_id);
INSERT INTO events (user_id, event_name, properties) VALUES
(1001, 'page_view', '{"page": "/dashboard"}'),
(1001, 'button_click', '{"button": "export"}'),
(1002, 'page_view', '{"page": "/settings"}'),
(1003, 'signup', '{}');
SELECT toDate(created_at) AS day, uniqExact(user_id) AS dau
FROM events
WHERE created_at >= now() - INTERVAL 30 DAY
GROUP BY day
ORDER BY day;
Bulk load a CSV file that has a header row (the container reads it from stdin):
docker exec -i clickhouse-server clickhouse-client -u analytics --password "$CLICKHOUSE_PASSWORD" \
--query "INSERT INTO events (user_id, event_name, properties, created_at) FORMAT CSVWithNames" < events.csv
Result: SELECT returns one row per day, for example 2026-10-24 3. Extract JSON fields with JSONExtractString(properties, 'page').
Example 2: Hourly rollup with distinct users, and 7-day signup retention
User request: "Give me hourly event counts with unique users that stay fast as the table grows, and tell me how many signups came back within a week"
CREATE TABLE hourly_event_stats (
hour DateTime,
event_name LowCardinality(String),
total SimpleAggregateFunction(sum, UInt64),
unique_users AggregateFunction(uniq, UInt64)
) ENGINE = AggregatingMergeTree
ORDER BY (hour, event_name);
CREATE MATERIALIZED VIEW mv_hourly_event_stats TO hourly_event_stats AS
SELECT toStartOfHour(created_at) AS hour, event_name,
count() AS
Установить clickhouse в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл clickhouse?
ClickHouse is a columnar OLAP database for real-time analytical queries over billions of rows. It speaks SQL, stores data in MergeTree tables, and rolls up data at insert time with materialized views. Use when the user wants to run ClickHouse in Docker, design MergeTree tables, load events or logs, write aggregation or retention queries, build rollups, or connect from Node.js. Trigger words: clickhouse, olap, mergetree, columnar database, analytics database.
Как установить скилл clickhouse?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл clickhouse запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic