altinity-expert-clickhouse/skills/altinity-expert-clickhouse-schema/SKILL.md
Analyze ClickHouse table structure, partitioning, ORDER BY keys, materialized views, and identify schema design anti-patterns. Use for table design issues and optimization.
npx skillsauth add altinity/skills altinity-expert-clickhouse-schemaInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Analyze table structure, partitioning, ORDER BY, materialized views, and identify design anti-patterns.
Run all queries from checks.sql in this skill's directory and analyze the results.
select
database,
table,
count() as partitions,
sum(rows) as total_rows,
formatReadableSize(sum(bytes_on_disk)) as total_size,
formatReadableSize(median(bytes_on_disk)) as median_partition_size,
min(partition) as oldest_partition,
max(partition) as newest_partition
from system.parts
where active and database = '{database}' and table = '{table}'
group by database, table, partition
order by partition desc
limit 100
select
name,
type,
formatReadableSize(data_compressed_bytes) as compressed,
formatReadableSize(data_uncompressed_bytes) as uncompressed,
round(data_uncompressed_bytes / nullIf(data_compressed_bytes, 0), 2) as ratio,
compression_codec
from system.columns
where database = '{database}' and table = '{table}'
order by data_compressed_bytes desc
limit 50
Look for:
select
database,
table,
name as index_name,
type,
expr,
granularity
from system.data_skipping_indices
where database = '{database}'
order by database, table
| Data Volume | Recommended Granularity | Example |
|-------------|------------------------|---------|
| < 10GB/month | No partitioning or yearly | toYear(ts) |
| 10-100GB/month | Monthly | toYYYYMM(ts) |
| 100GB-1TB/month | Weekly or daily | toMonday(ts) |
| > 1TB/month | Daily | toDate(ts) |
tenant_id, region)Anti-patterns:
| Data Type | Recommended Codec |
|-----------|-------------------|
| Integers (sequential) | Delta, ZSTD |
| Integers (random) | ZSTD or LZ4HC |
| Floats | Gorilla, ZSTD |
| Timestamps | DoubleDelta, ZSTD |
| Strings (long) | ZSTD(3) |
| Strings (repetitive) | LowCardinality + ZSTD |
| Finding | Load Module | Reason |
|---------|-------------|--------|
| Many small partitions | altinity-expert-clickhouse-ingestion | Check batch sizing |
| Oversized partitions | altinity-expert-clickhouse-merges | Merge can't complete |
| High PK memory | altinity-expert-clickhouse-memory | Memory pressure |
| MV performance issues | altinity-expert-clickhouse-reporting | Query analysis |
| Too many parts per partition | altinity-expert-clickhouse-merges | Merge backlog |
| Setting | Default | Recommendation |
|---------|---------|----------------|
| index_granularity | 8192 | Lower for point lookups, higher for scans |
| ttl_only_drop_parts | 0 | Set to 1 if TTL deletes entire partitions |
| min_bytes_for_wide_part | 10MB | Increase if many small parts |
tools
Read-only ClickHouse security audit expert for live or exported systems. Use when assessing ClickHouse security posture, reviewing users, roles, grants, settings profiles, row policies, table functions, external sources, table engines, executable UDFs, audit logs, named collections, password hash hygiene, SQL SECURITY DEFINER, impersonation, TLS/network exposure, Keeper/interserver security, encryption at rest, backups, the HTTP interface surface, cluster security, or version-specific ClickHouse security behavior. Diagnoses from SQL/system tables, supplied configuration files, query logs, access metadata, and ClickHouse/Altinity documentation.
tools
Diagnose and resolve ClickHouse grant and authentication errors, especially after upgrades. Use when queries fail with ACCESS_DENIED/NOT_ENOUGH_PRIVILEGES, AUTHENTICATION_FAILED/WRONG_PASSWORD/REQUIRED_PASSWORD, or ON CLUSTER privilege errors; when system.* or INFORMATION_SCHEMA access is denied; or when grant behavior changes after version upgrades.
tools
Profile a ClickHouse cluster via MCP and emit a per-cluster "analyst" Skill the user can save in claude.ai. Activate when the user asks to "profile this ClickHouse", "generate an analyst skill", "build a schema guide", "map the data in this cluster", or regenerate an existing cluster-analyst Skill after schema changes. Works against any ClickHouse with read-only SELECT/SHOW/DESCRIBE access via an `execute_query` MCP tool (e.g. the Altinity MCP server). Outputs a 5-file markdown bundle plus a README.
tools
Diagnose ClickHouse disk usage, compression efficiency, part sizes, and storage bottlenecks. Use for disk space issues and slow IO.