ClickHouse
Query, optimize, and administer ClickHouse OLAP databases with schema design, performance tuning, and data ingestion patterns.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/ivangdavila/clickhouseClickHouse š
Real-time analytics on billions of rows. Sub-second queries. No indexes needed.
Setup
On first use, read setup.md for connection configuration.
When to Use
User needs OLAP analytics, log analysis, time-series data, or real-time dashboards. Agent handles schema design, query optimization, data ingestion, and cluster administration.
Architecture
Memory lives in ~/clickhouse/. See memory-template.md for structure.
~/clickhouse/
āāā memory.md # Connection profiles + query patterns
āāā schemas/ # Table definitions per database
āāā queries/ # Saved analytical queries
Quick Reference
| Topic | File |
|---|---|
| Setup & connection | setup.md |
| Memory template | memory-template.md |
| Query patterns | queries.md |
| Performance tuning | performance.md |
| Data ingestion | ingestion.md |
Core Rules
1. Always Specify Engine
Every table needs an explicit engine. Default to MergeTree family:
-- Time-series / logs
CREATE TABLE events (
timestamp DateTime,
event_type String,
data String
) ENGINE = MergeTree()
ORDER BY (timestamp, event_type);
-- Aggregated metrics
CREATE TABLE daily_stats (
date Date,
metric String,
value AggregateFunction(sum, UInt64)
) ENGINE = AggregatingMergeTree()
ORDER BY (date, metric);
2. ORDER BY is Your Index
ClickHouse has no traditional indexes. The ORDER BY clause determines data layout:
- Put high-cardinality filter columns first
- Put range columns (dates, timestamps) early
- Match your most common WHERE patterns
-- Good: filters by user_id, then date range
ORDER BY (user_id, date, event_type)
-- Bad: date first when you filter by user_id
ORDER BY (date, user_id, event_type)
3. Use Appropriate Data Types
| Use Case | Type | Why |
|---|---|---|
| Timestamps | DateTime or DateTime64 | Native time functions |
| Low-cardinality strings | LowCardinality(String) | 10x compression |
| Enums with few values | Enum8 or Enum16 | Smallest footprint |
| Nullable only if needed | Nullable(T) | Adds overhead |
| IPs | IPv4 or IPv6 | 4 bytes vs 16+ |
4. Batch Inserts
Never insert row-by-row. ClickHouse is optimized for batch writes:
# Good: batch insert
clickhouse-client --query="INSERT INTO events FORMAT JSONEachRow" < batch.json
# Bad: individual inserts in a loop
for row in data:
INSERT INTO events VALUES (...)
Minimum batch: 1,000 rows. Optimal: 10,000-100,000 rows.
5. Prewarm Queries with FINAL
Queries on ReplacingMergeTree/CollapsingMergeTree need FINAL for accuracy:
-- May return duplicates/old versions
SELECT * FROM users WHERE id = 123;
-- Guaranteed latest version
SELECT * FROM users FINAL WHERE id = 123;
FINAL has performance cost. For dashboards, consider materialized views.
6. Materialized Views for Speed
Pre-aggregate expensive computations:
Metadata
Not sure this is the right skill?
Describe what you want to build ā we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-ivangdavila-clickhouse": {
"enabled": true,
"auto_update": true
}
}
}Related Skills
Arduino
Develop Arduino projects avoiding common wiring, power, and code pitfalls.
Bulgarian
Write Bulgarian that sounds human. Not formal, not robotic, not AI-generated.
Arabic
Write Arabic that sounds human. Not formal, not robotic, not AI-generated.
Assistant
Manage tasks, communications, and scheduling with proactive and organized support.
Alerts
Smart alerting patterns for AI agents - deduplication, routing, escalation, and fatigue prevention