Skip to content
Back to skills

Clickhouse Analytics

ASecurity

Design and query ClickHouse schemas fast: MergeTree ordering keys, partitioning, batch inserts and materialized views

  • 5 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 30, 2026
ai-agentssqldatabaseperformance

Works with

  • cli

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add AdityaaaTiwari/ANVIL --skill clickhouse-analytics --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Clickhouse Analytics?

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

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

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
---
description: Design and query ClickHouse schemas fast: MergeTree ordering keys, partitioning, batch inserts and materialized views
profile: standard
tags: clickhouse, analytics, database, performance
---

# ClickHouse analytics

Use when designing ClickHouse tables, materialized views, ingestion pipelines, or analytical SQL queries.

## MergeTree design
- Pick the **`ORDER BY`** tuple carefully around high-frequency filter columns from **lowest to highest cardinality** (e.g., `(tenant_id, event_type, toStartOfHour(ts), user_id)`). `ORDER BY` determines the physical sort and sparse primary index.
- Partition **`PARTITION BY`** coarsely (typically `toYYYYMM(ts)`, never by user ID or hour) so parts do not explode beyond limits and drops/TTLs run instantaneously.
- Avoid nullable columns (`Nullable(T)`) in `ORDER BY` or heavy scan columns when a sentinel/default (`LowCardinality(String)`) suffices; `Nullable` adds a separate null-mask file and slows scans.

## Ingestion and mutations
- Batch inserts (`10k–100k` rows per `INSERT` block or async inserts); never execute row-by-row HTTP `INSERT`s, which create excessive small parts and trigger `Too many parts`.
- Remember ClickHouse is append-optimized: avoid frequent `ALTER TABLE ... UPDATE/DELETE` mutations. Use **`ReplacingMergeTree`** (deduplicated with `FINAL` or `argMax` at query time) or TTL eviction instead.

## Materialized views
Pre-aggregate dashboard rollups via incremental **`Materialized View`** (`SummingMergeTree` / `AggregatingMergeTree` using `-State`/`-Merge` combinators) triggered on inserts.

## Verify
Benchmark bulk insert part count, inspect `EXPLAIN indexes = 1` for primary key pruning (`Granules`), and check query memory via `system.query_log`.

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.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.