Agent skill

Clickhouse Performance Tuning

by jeremylongshore in jeremylongshore/tons-of-skills-marketplace

Optimize ClickHouse query performance with indexing, projections, settings tuning, and query analysis using system tables.

MITAuto-check passedDatabases

Install Clickhouse Performance Tuning

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill clickhouse-performance-tuning -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace clickhouse-performance-tuning --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/clickhouse-performance-tuning .claude/skills/clickhouse-performance-tuning && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
clickhouse-performance-tuning
GitHub stars
2.8k
Token cost
~1.2k tokens
SKILL.md length
376 words
Files
3 (incl. references)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Optimize ClickHouse query performance with indexing, projections, settings tuning, and query analysis using system tables.

  • Works in 7 steps: Diagnose slow queries — rank the last… → ORDER BY key optimization — the primary… → Data skipping indexes — bloom_filter for… → …
  • Queries are slow
  • SKILL.md covers Overview, Prerequisites, Instructions and Output, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Clickhouse Performance Tuning is an agent skill from jeremylongshore/tons-of-skills-marketplace. 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".

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/examples.md` and `references/implementation.md`). Compatibility notes: Designed for Claude Code

It sits in Databases, covering Data warehousing and Query optimization. It works with ClickHouse. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Queries are slow
  • Investigating performance bottlenecks
  • Tuning ClickHouse server settings
  • With clickhouse performance

Example prompts

  • “clickhouse performance”
  • “optimize clickhouse query”
  • “clickhouse slow query”
  • “/clickhouse-performance-tuning”

Requirements

  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Diagnose slow queries — rank the last 24h of system.query_log by
  2. ORDER BY key optimization — the primary lever. Filtering on the ORDER BY prefix
  3. Data skipping indexes — bloom_filter for high-cardinality lookups, set for
  4. Projections — automatic pre-aggregation ClickHouse picks transparently when a
  5. Server settings — max_threads, external sort/group-by spill, async_insert,
  6. Materialized views — pre-aggregate on INSERT into an AggregatingMergeTree so
  7. Query patterns — PREWHERE, LIMIT BY, and avoiding FINAL.

What it can do on your machine

Read from SKILL.md and the folder at commit cfae287. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are sql).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • clickhouse.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Clickhouse Performance Tuning loads about 1.2k tokens when it runs, and up to ~3.2k if it reads all its reference files. Until then it costs about 105 tokens; SKILL.md has 376 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~105
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit cfae287, republished under its MIT licence (© jeremylongshore). 376 words, ~1,176 tokens.

Download SKILL.mdSave it as .claude/skills/clickhouse-performance-tuning/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
clickhouse-performance-tuning
description
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".
allowed-tools
Read, Write, Edit
compatibility
Designed for Claude Code
version
1.7.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
saas, database, analytics, clickhouse, olap

ClickHouse Performance Tuning

Overview

Diagnose and fix ClickHouse performance issues using query analysis, proper indexing, projections, materialized views, and server settings tuning. Work top-down: measure first with system.query_log, then apply the single highest-leverage fix (usually the ORDER BY key), then re-measure to confirm.

Prerequisites

  • ClickHouse tables with data (see clickhouse-core-workflow-a)
  • Access to system.query_log and system.parts

Instructions

The tuning workflow is seven independent steps. Diagnose first, then reach for the fix that matches the bottleneck. Each step's full SQL lives in references/implementation.md — start there for the complete, copy-paste commands.

  1. Diagnose slow queries — rank the last 24h of system.query_log by query_duration_ms, then inspect a suspect query with EXPLAIN PLAN / EXPLAIN PIPELINE.
  2. ORDER BY key optimization — the primary lever. Filtering on the ORDER BY prefix skips whole granules; a mismatched key forces a full scan.
  3. Data skipping indexes — bloom_filter for high-cardinality lookups, set for low-cardinality columns, minmax for range filters on non-key columns.
  4. Projections — automatic pre-aggregation ClickHouse picks transparently when a query matches the projection's shape.
  5. Server settings — max_threads, external sort/group-by spill, async_insert, and friends, set per-query or per-session.
  6. Materialized views — pre-aggregate on INSERT into an AggregatingMergeTree so dashboard reads hit milliseconds, not seconds.
  7. Query patterns — PREWHERE, LIMIT BY, and avoiding FINAL.

The essential first move — find the slowest queries:

sql
SELECT event_time, query_duration_ms, read_rows, read_bytes,
       substring(query, 1, 300) AS query_preview
FROM system.query_log
WHERE type = 'QueryFinish'
  AND event_time >= now() - INTERVAL 24 HOUR
  AND query_duration_ms > 1000   -- > 1 second
ORDER BY query_duration_ms DESC
LIMIT 20;
Show full SKILL.md (162 more words)Show less

Output

Applying this workflow produces:

  • A ranked list of the slowest queries with their read_rows / read_bytes cost.
  • One or more concrete schema/query changes: a corrected ORDER BY key, added data skipping indexes, a projection, a materialized view, or tuned session settings.
  • A before/after measurement from system.query_log proving the change reduced read_rows, read_bytes, query_duration_ms, or memory_usage.

Error Handling

IssueIndicatorSolution
Full table scanread_rows = total rowsFix ORDER BY to match filters
Memory exceededError 241Add LIMIT, use streaming, increase limit
Slow GROUP BYHigh read_bytesAdd materialized view or projection
Merge backlogParts > 300Reduce insert frequency, increase merge threads

Examples

Worked before/after scenarios — full-scan → ORDER BY fix, slow GROUP BY → projection, confirming a skipping index fires, and the query-cost measurement query — are in references/examples.md. The core measurement, run right after any query you are tuning:

sql
SELECT query_duration_ms, read_rows,
       formatReadableSize(read_bytes) AS read_size,
       formatReadableSize(memory_usage) AS memory
FROM system.query_log
WHERE query_id = currentQueryId() AND type = 'QueryFinish';

Resources

Next Steps

For cost optimization, see clickhouse-cost-tuning.

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (references) in skills/.curated/clickhouse-performance-tuning of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • references/examples.md
  • references/implementation.md

Open the folder on GitHubat commit cfae287

Compare with similar skills

Clickhouse Performance Tuning next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Clickhouse Performance Tuning compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Clickhouse Performance Tuning this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.2kAutomated safety check: PassMIT
Clickhouse Ioaffaan-m/ECC277k1 repos~2.7kAutomated safety check: PassMIT
Generating Clickhouse Query Performance ReportsPostHog/posthog40k—~5.1kAutomated safety check: PassCustom licence
Pytorch Clickhousepytorch/test-infra113—~2.8kAutomated safety check: PassCustom licence
Clickhouse IohellangleZ/burn-in-cceverywhere-ralph11214 repos~2.5kAutomated safety check: PassNone
Clickhouse System QueriesFrankChen021/datastoria327—~731Automated safety check: PassCustom licence

Similar skills

  • Clickhouse Io

    affaan-m/ECC

    ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.

    277k GitHub starsUsed in 1 repo~2.7k tokens
    DatabasesAuto-check passed
  • Produce and structure slow-query performance reports for PostHog's production ClickHouse (US and EU).

    40k GitHub stars~5.1k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Pytorch Clickhouse

    pytorch/test-infra

    Load this FIRST whenever working with PyTorch CI data (any pytorch/ org repo), the torchci/HUD codebase, or the PyTorch HUD ClickHouse database.

    113 GitHub stars~2.8k tokensUpdated today
    DatabasesAuto-check passed
  • Clickhouse Io

    hellangleZ/burn-in-cceverywhere-ralph

    ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.

    112 GitHub starsUsed in 14 repos~2.5k tokens
    DatabasesAuto-check passed
  • Clickhouse System Queries

    FrankChen021/datastoria

    Query ClickHouse system tables to inspect query logs, monitor cluster health, check replication status, and analyze slow queries.

    327 GitHub stars~731 tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • Clickhouse Managed Postgres Rca

    ClickHouse/agent-skills

    MUST USE when investigating performance issues on a ClickHouse-managed Postgres instance.

    545 GitHub stars~1.2k tokensUpdated 12 days ago
    DatabasesAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated today
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Clickhouse Performance Tuning

What does Clickhouse Performance Tuning do?

Optimize ClickHouse query performance with indexing, projections, settings tuning, and query analysis using system tables. Clickhouse Performance Tuning is an agent skill from jeremylongshore/tons-of-skills-marketplace. Optimize ClickHouse query performance with indexing, projections, settings tuning, and query analysis using system tables.

When should I use Clickhouse Performance Tuning?

Clickhouse Performance Tuning fits situations like: queries are slow; investigating performance bottlenecks; tuning ClickHouse server settings; with clickhouse performance.

How do I install Clickhouse Performance Tuning in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill clickhouse-performance-tuning -a claude-code`. Or copy the skill folder (skills/.curated/clickhouse-performance-tuning in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/clickhouse-performance-tuning in your project. Claude Code loads it when a task matches its description.

How do I install Clickhouse Performance Tuning in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill clickhouse-performance-tuning -a codex`. Or copy the skill folder (skills/.curated/clickhouse-performance-tuning in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/clickhouse-performance-tuning in your project. Codex loads it when a task matches its description.

Can I use Clickhouse Performance Tuning in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill clickhouse-performance-tuning -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/clickhouse-performance-tuning, .gemini/skills/clickhouse-performance-tuning, .github/skills/clickhouse-performance-tuning and .opencode/skills/clickhouse-performance-tuning in your project.

What does Clickhouse Performance Tuning need to run?

SKILL.md names no scripts, command-line tools or credentials: Clickhouse Performance Tuning is instructions for the agent only. Its frontmatter pre-approves these tools: Read, Write, Edit. Compatibility (from SKILL.md): Designed for Claude Code.

Does Clickhouse Performance Tuning access the network?

SKILL.md names 1 domain. As links in the text: clickhouse.com. This is read from the text; nothing was executed.

Is Clickhouse Performance Tuning safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Clickhouse Performance Tuning use?

Clickhouse Performance Tuning is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Clickhouse Performance Tuning use?

About 1.2k tokens (SKILL.md is roughly 4.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.1k tokens, read only when the agent opens those files.

What are the alternatives to Clickhouse Performance Tuning?

Skills that share tags, products or a category with Clickhouse Performance Tuning: Clickhouse Io (affaan-m/ECC, 277k stars), Generating Clickhouse Query Performance Reports (PostHog/posthog, 40k stars), Pytorch Clickhouse (pytorch/test-infra, 113 stars) and Clickhouse Io (hellangleZ/burn-in-cceverywhere-ralph, 112 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Clickhouse Performance Tuning?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,827 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 10, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.