---
name: "clickhouse-high-throughput-insert"
description: "Ingest and query billions of events with ClickHouse columnar database engine."
metadata:
  author: "ClickHouse"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "insert batch clickhouse"
  - "configure mergetree table"
  - "enable async insert clickhouse"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# ClickHouse High-Throughput Batch Inserts

Optimizes ClickHouse data ingestion and storage: MergeTree table engines, primary key sorting keys, async inserts (async_insert=1), batching protocols, and partitioned data compression.

## When to Invoke
Invoke this skill whenever you need to:
- insert batch clickhouse
- configure mergetree table
- enable async insert clickhouse

## Execution SOP & Rules
1. Design tables using ENGINE = MergeTree() ORDER BY (tenant_id, event_time, user_id).
2. Partition by month or day: PARTITION BY toYYYYMM(event_time); avoid granular partitioning.
3. Batch inserts in chunks of 50,000 to 100,000 rows, or enable async_insert on the server.
4. Use low-cardinality types: LowCardinality(String) for columns with under 10,000 unique values.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
