Skip to content
Back to skills

Clickhouse

ASecurity

Design and operate ClickHouse for OLAP analytics: columnar tables, engines, aggregations, partitioning, and performance. Use for analytics workloads.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 1, 2026
ai-agentspythongobashsqldockerdatabasebackendperformance

Works with

  • cli

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 2 files and shows the line behind each finding

Scanned October 1, 2026

npx -y skills add ssrjkk/agent-skills --skill clickhouse --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Clickhouse?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Clickhouse
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ssrjkk-clickhouse/badge)](https://www.skillsdirectory.com/skills/ssrjkk-clickhouse)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: clickhouse
description: "Design and operate ClickHouse for OLAP analytics: columnar tables, engines, aggregations, partitioning, and performance. Use for analytics workloads."
category: database
tags: [clickhouse, olap, columnar, analytics, aggregations, partitioning]
models: [sonnet, opus, gpt-6, gemini-3, glm-5]
version: 1.0.0
created: 2026-09-29
updated: 2026-09-29
author: ssrjkk
---
# ClickHouse

> Columnar OLAP analytics with ClickHouse.

## Quick Start
```bash
docker run -p 8123:8123 -d clickhouse/clickhouse-server
clickhouse-client
```

## When to Use
- High-volume analytics and reporting
- Aggregations over large event datasets
- Timeseries and log analysis
- Dashboards and BI backends

## Best Practices

### Schema
- Use columnar MergeTree engines
- Choose the right engine (MergeTree, Replacing, Summing)
- Use LowCardinality for low-cardinality strings
- Pick types deliberately (DateTime, UInt, Float64)

### Partitioning & Order
- Partition by time for retention and scans
- Set ORDER BY to match filter/sort patterns
- Use TTL for data lifecycle
- Keep partitions balanced in size

### Querying
- Aggregate with GROUP BY; use materialized views
- Filter early; avoid SELECT * on wide tables
- Use sampling for very large results
- Leverage `argMax`, `uniq`, and `quantile` functions

### Operations
- Monitor disk, CPU, and query performance
- Use `system.query_log` for diagnostics
- Back up parts and metadata
- Distribute with Distributed tables when needed

## Dependencies
```bash
docker run -p 8123:8123 -d clickhouse/clickhouse-server
# Python: pip install clickhouse-connect
```

## Examples
```sql
-- Columnar table with TTL and partition
CREATE TABLE events (
  ts DateTime,
  user_id UInt64,
  action LowCardinality(String),
  value Float64
) ENGINE = MergeTree
PARTITION BY toYYYYMM(ts)
ORDER BY (user_id, ts)
TTL toDateTime(ts) + INTERVAL 90 DAY;
```
```sql
-- Aggregation query
SELECT
  toDate(ts) AS day,
  uniq(user_id) AS active_users,
  sum(value) AS total
FROM events
WHERE ts >= now() - INTERVAL 7 DAY
GROUP BY day
ORDER BY day;
```
```sql
-- Quantiles and argMax
SELECT
  quantile(0.95)(value) AS p95,
  argMax(action, ts) AS last_action
FROM events;
```
```python
import clickhouse_connect

client = clickhouse_connect.get_client(host="localhost", port=8123)
rows = client.query("SELECT count() FROM events").result_rows
print(rows)
```

## Step-by-Step
1. Choose the MergeTree engine and table layout.
2. Set partitioning and ORDER BY for access patterns.
3. Add TTL for retention.
4. Write aggregations with the right functions.
5. Add materialized views for hot aggregations.
6. Monitor query_log and disk.
7. Tune max_threads and memory.
8. Back up and plan scaling.

## Validation
1. Aggregations return correct results
2. Queries scan minimal partitions
3. TTL removes expired data
4. Query latency within budget at scale
5. Backups restore correctly

## Troubleshooting
- Slow queries: check partitions scanned and ORDER BY.
- High disk: adjust TTL and partition size.
- Memory errors: lower max_memory_usage or optimize queries.

Files in this skill

  • SKILL.md3 KB
  • SKILL.ru.md4.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…