Skip to content
Skills Library
Data & analytics · Building & coding

clickhouse

/clickhouse

Expert ClickHouse columnar database assistance covering MergeTree engines, materialized views, vector search, and real-time ingestion. Use when querying analytical telemetry, logs, time-series data, or building analytics APIs.

Licence
MIT
Last repository change
01.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 01.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Expert ClickHouse columnar database assistance covering MergeTree engines, materialized views, vector search, and real-time ingestion. Use when querying analytical telemetry, logs, time-series data, or building analytics APIs.

Original author description

Expert ClickHouse columnar database assistance covering MergeTree engines, materialized views, vector search, and real-time ingestion. Use when querying analytical telemetry, logs, time-series data, or building analytics APIs.

How it works

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Original SKILL.md headings · 141 lines, 617 words
SKILL.md preview
---
name: clickhouse
description: Expert ClickHouse columnar database assistance covering MergeTree engines, materialized views, vector search, and real-time ingestion. Use when querying analytical telemetry, logs, time-series data, or building analytics APIs.
---

# ClickHouse

ClickHouse is a columnar DBMS for Online Analytical Processing (OLAP). It is famous for allowing real-time generation of analytical reports using SQL queries on petabytes of data.

## When to Use

- **Real-Time OLAP Analytics**: Aggregating billions of rows per second for real-time dashboards, security SIEMs, and web analytics.
- **High-Compression Columnar Storage**: Compressing raw event logs by 80-90% using LZ4 and ZSTD column-level codecs.
- **Ad-Hoc Analytical Queries**: Executing complex aggregations, window functions, and multi-billion-row vector queries in milliseconds.
- **Observability Data Stores**: Powering log and trace storage backends (e.g. replacing Elasticsearch for OpenTelemetry metrics and logs).

## Quick Start

```sql
SELECT
    toStartOfHour(EventTime) as Hour,
    count(),
    avg(Duration)
FROM events
GROUP BY Hour
ORDER BY Hour
```

## Core Concepts

### MergeTree Engine Family

The foundational storage engine for ClickHouse; writes data in immutable sorted parts and merges them asynchronously in the background:

```sql
CREATE TABLE analytics.page_views
(
    event_time DateTime64(3, 'UTC'),
    site_id UInt32,
    user_id UUID,
    url_path LowCardinality(String),
    response_time_ms UInt16,
    user_agent String CODEC(ZSTD(3))
)
ENGINE = MergeTree()
PARTITION BY toYYYYMM(event_time)
ORDER BY (site_id, event_time, user_id)
SETTINGS index_granularity = 8192;
```

### Materialized Views with AggregatingMergeTree

Precomputes rolling aggregations at insertion time with zero background batch job overhead:

```sql
-- Pre-aggregated Hourly Metrics
CREATE TABLE analytics.hourly_traffic
(
    hour DateTime,
    site_id UInt32,
    total_views SimpleAggregateFunction(sum, UInt64),
    unique_visitors AggregateFunction(uniq, UUID)
)
ENGINE = AggregatingMergeTree()
ORDER BY (site_id, hour);

CREATE MATERIALIZED VIEW analytics.hourly_traffic_mv TO analytics.hourly_traffic AS
SELECT
    toStartOfHour(event_time) AS hour,
    site_id,
    count() AS total_views,
    uniqState(user_id) AS unique_visitors
FROM analytics.page_views
GROUP BY hour, site_id;
```

### Vectorized SIMD Query Execution

ClickHouse processes data in vectorized arrays of column primitives, utilizing hardware CPU SIMD instructions to aggregate millions of values per cycle:

```sql
-- Sub-10ms aggregation over 50,000,000 rows
SELECT
    url_path,
    count() AS hits,
    quantile(0.95)(response_time_ms) AS p95_latency
FROM analytics.page_views
WHERE event_time >= now() - INTERVAL 24 HOUR
GROUP BY url_path
ORDER BY hits DESC
LIMIT 10;
```

## Common Patterns

### ReplacingMergeTree for Deduplicated Real-Time Analytics

**Problem**: High-speed real-time event streaming frequently delivers duplicate logs or updated state rows.

**Solution**:
Use `ReplacingMergeTree` with primary sorting key:

```sql
CREATE TABLE telemetry.sensor_metrics (
  sensor_id UInt32,
  recorded_at DateTime64(3),
  reading Float64,
  version UInt64
)
ENGINE = ReplacingMergeTree(version)
ORDER BY (sensor_id, recorded_at);

-- Query latest state across parts
SELECT sensor_id, recorded_at, reading
FROM telemetry.sensor_metrics FINAL
WHERE sensor_id = 101;
```

## Best Practices

**Do**:

- Insert in Large Batches: Stream data in batches of 10,000 to 100,000 rows (or at 1-second intervals) to prevent creating excessive small parts.
- Use `LowCardinality(String)`: Compress string columns with fewer than 10,000 unique values into indexed integer dictionaries.
- Order by Most-Filtered Columns First: Arrange primary sort keys from lowest cardinality to highest cardinality (`site_id`, `event_time`, `user_id`).
- Use `ReplacingMergeTree` for Deduplication: Deduplicate rows based on version numbers during background merges.

**Don't**:

- Perform single-row `INSERT` statements: Inserting single rows overwhelms the MergeTree engine and exhausts filesystem inodes.
- Use ClickHouse for transactional OLTP: ClickHouse does not support ACID row locking, single-record updates, or foreign key cascades.
- Create too many partitions: Keep partition counts under 1,000 per table; partition by month (`toYYYYMM`) rather than day.

## Troubleshooting

| Error                                 | Cause                                                               | Solution                                                                              |
| :------------------------------------ | :------------------------------------------------------------------ | :------------------------------------------------------------------------------------ |
| `Too many parts in all data in table` | Ingesting too many tiny micro-batches instead of large batches.     | Buffer writes into batches of 10,000+ rows or use an asynchronous insert buffer.      |
| `Memory limit exceeded for query`     | Query scanning uncompressed memory without proper partition filter. | Add `WHERE` filter on the primary key sorting prefix, or increase `max_memory_usage`. |
| `DB::Exception: Cannot parse input`   | Schema type mismatch during CSV/JSON ingestion.                     | Verify data format and use `input_format_skip_unknown_fields = 1`.                    |

## References

- [ClickHouse Documentation](https://clickhouse.com/docs)

Versions

RepositoryScoreLicence
This page · G1Joshi/Agent-Skills100MIT
speakeasy-api/gram100AGPL-3.0
TerminalSkills/skills100Apache-2.0
dkbnull/hello-skill86MIT

Database snapshot: 13.11.2026 · package version b3c1307dc92e (SHA-256 digest of the entire package)

Downloads in the last 30 days: 2 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100clickhouse-analytical-database-operations
    Covers operating ClickHouse, the leading open-source OLAP columnar database: MergeTree engine family selection (MergeTree, ReplacingMergeTree, AggregatingMergeTree, SummingMergeTree), sharding and replication topology via ReplicatedMergeTree and Distributed tables, and…
  • 100clickhouse-core-workflow-a
    Design ClickHouse schemas with MergeTree engines, ORDER BY keys, and partitioning. Use when creating new tables, choosing an engine, designing sort keys, or modeling data for analytical workloads on ClickHouse or ClickHouse Cloud. Trigger with "clickhouse schema design",…
  • 100clickhouse-olap-analytical-database
    Use this skill when executing real-time analytical queries over billions of rows using ClickHouse columnar engines.
  • 100clickhouse-core-workflow-b
    Insert, query, and aggregate data in ClickHouse with real SQL patterns. Use when writing analytical queries, inserting data at scale, building dashboards, or implementing materialized views for pre-aggregation. Trigger with "clickhouse query", "clickhouse insert", "clickhouse…
  • 100clickhouse-analytics
    Use when running a ClickHouse server for high-volume OLAP: choosing a MergeTree engine and ORDER BY/PARTITION BY keys, ingesting billions of event/log/metric rows, pre-aggregating with materialized views, or fixing a query that scans instead of pruning. NOT in-process file…
  • 100clickhouse-analytics
    Designs ClickHouse schemas and queries for fast analytics - MergeTree engine selection, ORDER BY key design, partitioning, materialized views, and projections. Use when someone asks "why is my ClickHouse query slow", "how should I order my sorting key", "should I use a…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.