Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/clickhouse-performance-tuning

@0d57af8
Run it yourself

Optimize ClickHouse query performance with indexing, projections, settings tuning, and query analysis using system tables. Use when queries are slow, investigating performance bottlenecks, or tuning ClickHouse server settings. Trigger with "clickhouse performance", "optimize clickhouse query", "clickhouse slow query", "clickhouse indexing", "clickhouse tuning", "clickhouse projections".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/clickhouse-performance-tuning

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesexamples.md

≈486 tokens on demand. Your agent reads this file only when SKILL.md points to it.

ClickHouse Performance Tuning — Worked Examples

Concrete before/after scenarios and the measurement queries that prove a change worked.

Example 1: Measure a query's cost

Every tuning decision should be backed by a measurement. Run the query, then read its row from system.query_log to see exactly how much data it touched.

-- Measure bytes read and time for a specific query
SELECT
    query_duration_ms,
    read_rows,
    formatReadableSize(read_bytes) AS read_size,
    result_rows,
    formatReadableSize(memory_usage) AS memory
FROM system.query_log
WHERE query_id = currentQueryId()
  AND type = 'QueryFinish';

Example 2: Full table scan → ORDER BY fix

Symptom: a dashboard query on analytics.events reads every row.

-- Before: read_rows equals the full table size
EXPLAIN indexes = 1
SELECT event_type, count()
FROM analytics.events
WHERE tenant_id = 1 AND event_type = 'purchase'
GROUP BY event_type;

The table was ORDER BY (created_at), so the tenant_id/event_type filter could not skip granules. Recreating it with ORDER BY (tenant_id, event_type, toDate(created_at)) (see implementation.md Step 2) lets the same query skip every granule outside tenant_id = 1, cutting read_rows by orders of magnitude.

Example 3: Slow GROUP BY → projection

Symptom: an hourly rollup scans the whole table on every load.

Add the events_by_hour projection (Step 4). After MATERIALIZE PROJECTION, re-run the query and confirm the projection is used — read_bytes should drop sharply because the query now reads the small pre-aggregated part instead of the base table.

Example 4: Confirm a data skipping index fires

-- After ADD INDEX + MATERIALIZE INDEX, the plan should show the index
EXPLAIN indexes = 1
SELECT * FROM analytics.events WHERE session_id = 'abc-123';
-- Look for the idx_session_id entry with a reduced granule count.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides standard SQL templates for ClickHouse performance tuning. It is functional and well-structured, though it contains a minor surface for indirect prompt injection by processing database query logs that may contain user-controlled input.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 4 months ago
What it can do
Reads files Edits files
version
1.7.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
[
  "saas",
  "database",
  "analytics",
  "clickhouse",
  "olap"
]
All 3 allowed tools
ReadWriteEdit
Other metadata
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/clickhouse-performance-tuning