Agent skill

ClickHouse Query Performance Validation

by comet-ml in comet-ml/opik

Measures what a ClickHouse query change actually costs, turning a suspicion that a query is slow into numbers a reviewer can act on before it merges.

Apache-2.0Auto-check passedDatabases

Install ClickHouse Query Performance Validation

skills CLI
$ npx skills add comet-ml/opik --skill query-performance -a claude-code

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

GitHub CLI
$ gh skill install comet-ml/opik query-performance --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/comet-ml/opik.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/query-performance .claude/skills/query-performance && 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
query-performance
GitHub stars
22k
Token cost
~2.1k tokens
SKILL.md length
1,258 words
Files
4
Skills in repo
19
Repo updated
First seen
Licence
Apache-2.0

At a glance

Measures what a ClickHouse query change actually costs, turning a suspicion that a query is slow into numbers a reviewer can act on before it merges.

  • Works in 7 steps: Measure, never infer. Every claim needs… → Equivalence gate first. No variant's… → Collect the whole picture per run:… → …
  • Reviewing a DAO or query change before it merges
  • SKILL.md covers Ground rules, Assumptions to verify rather…, The loop and Deciding: does the change stay…, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

This skill sets rules for proving a ClickHouse query's cost rather than guessing at it. Every claim needs a measurement that would come out differently if the claim were false, and an equivalence check comes first: a variant is not comparable until it is shown to return the same rows, in the same order when the query defines one, as the query it varies. The main branch is treated as the cost reference, not a result reference, since a candidate is often meant to change what comes back.

Each run collects latency, peak memory, CPU time and what was scanned, because a variant can read fewer rows while costing more memory or CPU. At least two data shapes are measured, since rankings flip with density and skew, and each variant changes one variable at a time, including removing a clause outright to see if it earns its place. Five or more runs are required, reported as p50, p90, p95 and minimum, with more runs when a tail quantile is the deciding number.

A section of assumptions to verify rather than trust warns that a CTE referenced multiple times may be evaluated multiple times since named CTEs are not materialized, and that plan node count is not the same as evaluation count. The output is a verdict per clause, change, keep, or caller's call, each attached to a measurement, along with the negative results so nobody retries them. What could not be measured, such as quotas or cache state, is written down as a caveat.

When your agent uses it

  • Reviewing a DAO or query change before it merges
  • Investigating why an endpoint has become slow
  • Answering a reviewer who asks what a query costs at scale
  • Deciding whether a query clause is pulling its weight

Example prompts

  • “Measure whether removing the ORDER BY in this trace query actually helps at 500k rows.”
  • “Compare this candidate query against main on both a sparse and a dense dataset.”
  • “A reviewer asked what this join costs at 1M entities. Get me real numbers.”
  • “Check whether this CTE is being evaluated twice and costing us memory.”

Requirements

  • A ClickHouse environment with read-only access, or a Testcontainers dataset to extrapolate from

Workflow steps

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

  1. Measure, never infer. Every claim needs a number that would differ if the claim were false.
  2. Equivalence gate first. No variant's cost is quotable until you have ensured it returns the
  3. Collect the whole picture per run: latency, peak memory, CPU time, and what was scanned (parts,
  4. Two data shapes minimum, since rankings flip with density and skew. A win on one shape is a
  5. One variable per variant, including deleting a clause outright to see if it earns its keep.
  6. ≥5 runs; report p50, p90, p95 and min. Differences smaller than the spread are not
  7. Write down what you could not measure — quotas, unreachable shapes, cache state. Those

What it can do on your machine

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

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

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

  • Network

    No URLs in SKILL.md.

    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.

Context cost

ClickHouse Query Performance Validation loads about 2.1k tokens when it runs. Until then it costs about 83 tokens; SKILL.md has 1,258 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~83
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

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 comet-ml/opik at commit f217a86, republished under its Apache-2.0 licence (© comet-ml). 1,258 words, ~2,095 tokens.

Download SKILL.mdSave it as .claude/skills/query-performance/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
query-performance
description
Validate what a ClickHouse query actually costs before merging it — at production scale through read-only environment access, or on a revived Testcontainers dataset extrapolated to 20k/500k/1M entities. Use when a DAO query changes, when an endpoint is slow, or when a reviewer asks "what does this cost at scale".

Query Performance Validation

Turn "this query looks expensive" into numbers a reviewer can act on. The output is a verdict per clause — change, keep, or caller's call — each attached to a measurement, plus the negative results so nobody retries them.

Ground rules

  1. Measure, never infer. Every claim needs a number that would differ if the claim were false.
  2. Equivalence gate first. No variant's cost is quotable until you have ensured it returns the same result as the query it varies, on every shape you measure. Where the query defines an order — anything with ORDER BY, and anything paginated, where order decides which rows land on the page — the comparison must include that order; compare order-independently only when the result genuinely has no defined order. A faster query that answers a different question is not an optimization. (Equivalence holds between the candidate and its variants. A candidate is often meant to change results versus main; main is the cost reference, not a result reference.)
  3. Collect the whole picture per run: latency, peak memory, CPU time, and what was scanned (parts, granules, marks, rows read). The first three are what the system pays; the scan numbers are the evidence that explains why they moved. A variant can read fewer rows and still cost more memory, more CPU and the same wall time — so no single number decides anything on its own.
  4. Two data shapes minimum, since rankings flip with density and skew. A win on one shape is a hypothesis.
  5. One variable per variant, including deleting a clause outright to see if it earns its keep.
  6. ≥5 runs; report p50, p90, p95 and min. Differences smaller than the spread are not differences, and the tail is where a polled endpoint hurts. Tail quantiles are only as good as the run count — if p90/p95 is what you are deciding on, run more than five.
  7. Write down what you could not measure — quotas, unreachable shapes, cache state. Those caveats bound the finding.

Assumptions to verify rather than trust

The failure mode of this work is a confident mechanism the engine does not implement.

  • A CTE referenced N times may be evaluated N times. Named CTEs are not materialized. Probe it: same query, one reference vs two, compare marks and peak memory.
  • Plan node count is not evaluation count. Sets for IN (SELECT …) are often built eagerly and appear only as a literal (x in 35297-element set) with no read node — so counting ReadFromMergeTree nodes undercounts work, and a dominant subquery can be invisible.
  • EXPLAIN executes scalar and set subqueries to resolve index conditions: it is neither free nor a timing proxy.
  • Fewer rows read is not faster, and prune sets themselves cost memory.
  • An index existing is not an index used — read granule counts, not the schema.
  • A prune that pays on one shape can be dead weight on another, including one justified by a benchmark on synthetic data.
  • Container data is not production shape (parts, versions per key, cardinality, array density).
  • A read-only role can change the experiment: row-read caps abort long queries, and a restricted profile may refuse the settings your measurement needs.

The loop

  1. Frame it. Which endpoint, which call sites (one constant serving a list page and a by-id lookup behaves differently), how often called, what it is constrained on.
  2. Render the SQL for each call site, from the candidate and from main — see rendering.md.
  3. Inventory the query before measuring it. Read it and write down: the entity that drives it; every CTE and subquery with how many times each is referenced; which clauses are prunes (a clause you could delete without changing results) versus load-bearing; every dedup, set build, aggregation and join. This inventory is what tells you which probes are worth running — without it you will measure the query you assumed rather than the one you have.
  4. Get an environment: read-only access to a real one, else revive Testcontainers and extrapolate — see environments.md.
  5. Baseline both: the candidate and main, ≥5 runs each, plan captured per call site, shape recorded alongside. The delta between them is the cost of the change, and it is a finding in its own right — often the one that matters most.
  6. Locate the cost — see instrumentation.md. Isolate the suspect subquery and measure end-to-end; a gap between them is itself a finding.
  7. Work the inventory, one variable at a time. Take each clause from step 3 and ask what it costs and whether it earns its keep: prunes get ablated, repeated references get a reference-count probe, dedup and aggregation steps get an alternative formulation, expensive predicates get a cheaper one. For each: state the metric you expect to move, gate it, measure on both shapes and every call site, then keep or discard fast — and keep the number either way, including for what failed.
Show full SKILL.md (445 more words)Show less

Deciding: does the change stay or drop

Put the four measured dimensions side by side — latency (p50, p90, p95, min), peak memory, CPU time, scanned/read (parts, granules, marks, rows) — for every shape and every call site, and decide from the whole set:

  • Stays if it improves at least one dimension the call site is constrained on and regresses none of the others materially, on every shape and call site measured.
  • Drops if any dimension regresses materially and nothing the call site cares about improves — including when the scan shrinks. Less scanned work bought with more memory or CPU is a trade, and on a shared cluster memory is usually the scarcer resource.
  • Caller's call when dimensions genuinely conflict (better latency, worse memory) or when the ranking flips between shapes or call sites. Present both sets of numbers and name the trade rather than picking silently.
  • No change if every difference is inside the run-to-run spread: keep the simpler form, and say the variant was measured and made no difference.

Make the scan numbers do their job: they should explain the latency, CPU and memory you measured. If they do not — scan is flat but memory doubled, or rows fell but CPU rose — you have not found the mechanism yet, and the verdict is not ready.

Reporting

Whether you are reviewing a PR or opening one, justify every claim with a before/after table — one row per variant (or per revision), one column per measured dimension:

variantp50 msp90 msp95 msCPU mspeak MiBpartsgranules (marks)rows read
main……………………
candidate (before)……………………
with the change (after)……………………

The scan columns are not optional: they are what makes the other three explainable, so carry the pruning evidence into the table rather than only the totals.

One table per call site and per shape, with the shape named (entity counts, run count). A verdict without its table is an opinion, and prose alone hides exactly the trade a reviewer needs to see.

Lead with what the change itself costs against main, per call site — a tuning delta of a few percent does not outrank the endpoint getting materially more expensive, and if that cost is not acceptable, say so and name the lever that would actually move it.

Then per clause: change (the replacement, why, before → after table), keep (what you tried and the number that killed it), or caller's call (both options, trade named). Then the equivalence evidence and the caveats. Do not include optimizations you did not measure, or a mechanism you did not verify.

opik-backend (clickhouse.md, testing.md) — DAO and ClickHouse conventions, plus the Testcontainers rules including "one ClickHouse-migrating test class per mvn invocation".

© comet-ml, Apache-2.0. 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 3 other files in .agents/skills/query-performance of comet-ml/opik.

  • SKILL.md
  • environments.md
  • instrumentation.md
  • rendering.md

Open the folder on GitHubat commit f217a86

Compare with similar skills

ClickHouse Query Performance Validation 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 Query Performance Validation compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
ClickHouse Query Performance Validation this skillcomet-ml/opik22k—~2.1kAutomated safety check: PassApache-2.0
Pytorch Clickhousepytorch/test-infra113—~2.8kAutomated safety check: PassCustom licence
Clickhouse Ioaffaan-m/ECC274k1 repos~2.7kAutomated safety check: PassMIT
Generating Clickhouse Query Performance ReportsPostHog/posthog-foss721—~5.1kAutomated safety check: PassMIT
Performancekid-sid/claude-spellbook189—~3.8kAutomated safety check: PassMIT
Django Filter Benchmarksaleor/saleor23k—~2.3kAutomated safety check: PassBSD-3-Clause

Similar skills

  • 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

    affaan-m/ECC

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

    274k 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).

    721 GitHub stars~5.1k tokensUpdated today
    DatabasesAuto-check passed
  • Performance

    kid-sid/claude-spellbook

    A skill your agent uses when diagnosing a slow HTTP endpoint or high-latency service — profiling, adding an application-level cache, offloading CPU-bound work to threads or workers, or defining a…

    189 GitHub stars~3.8k tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • Benchmarks Django ORM filters in Saleor by generating bulk data, extracting the SQL and running EXPLAIN ANALYZE to check index usage.

    23k GitHub stars~2.3k tokensUpdated yesterday
    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

More from comet-ml/opik

All 19 skills in this repo
  • Checklist for wiring a new linter into Opik's Code Quality pipeline: the four files to edit, the silent-failure gotchas and the pass/fail verification loop.

    22k GitHub stars~2.3k tokensUpdated today
    Auto-check passed
  • Shows how to add product analytics events to Opik's frontend, Java backend and Python SDK, all reporting through Segment to PostHog with an opik_ name prefix.

    22k GitHub stars~4.4k tokensUpdated today
    Auto-check passed
  • Investigates a failed Opik end-to-end test from CI, TestOps or a local run, decides regression versus flake, and proposes a fix without editing tests.

    22k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Rules for writing PR descriptions, changelog entries and feature documentation in the Opik repository, including the exact headings that CI requires.

    22k GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Turns a code change into one committed, passing Playwright end-to-end spec by resolving the change scope and handing authoring to a companion skill.

    22k GitHub stars~3.4k tokensUpdated today
    Auto-check passed
  • Starts, rebuilds, and troubleshoots the Opik local dev stack, including an optional Comet Platform integration mode for the Opik team.

    22k GitHub stars~734 tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about ClickHouse Query Performance Validation

What does ClickHouse Query Performance Validation do?

Measures what a ClickHouse query change actually costs, turning a suspicion that a query is slow into numbers a reviewer can act on before it merges. This skill sets rules for proving a ClickHouse query's cost rather than guessing at it. Every claim needs a measurement that would come out differently if the claim were false, and an equivalence check comes first: a variant is not comparable until it is shown to return the same rows, in the same order when the query defines one, as the query it varies.

When should I use ClickHouse Query Performance Validation?

ClickHouse Query Performance Validation fits situations like: reviewing a DAO or query change before it merges; investigating why an endpoint has become slow; answering a reviewer who asks what a query costs at scale; deciding whether a query clause is pulling its weight.

How do I install ClickHouse Query Performance Validation in Claude Code?

Run `npx skills add comet-ml/opik --skill query-performance -a claude-code`. Or copy the skill folder (.agents/skills/query-performance in comet-ml/opik) into .claude/skills/query-performance in your project. Claude Code loads it when a task matches its description.

How do I install ClickHouse Query Performance Validation in Codex?

Run `npx skills add comet-ml/opik --skill query-performance -a codex`. Or copy the skill folder (.agents/skills/query-performance in comet-ml/opik) into .agents/skills/query-performance in your project. Codex loads it when a task matches its description.

Can I use ClickHouse Query Performance Validation 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 comet-ml/opik --skill query-performance -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/query-performance, .gemini/skills/query-performance, .github/skills/query-performance and .opencode/skills/query-performance in your project.

What does ClickHouse Query Performance Validation need to run?

SKILL.md names no scripts, command-line tools or credentials: ClickHouse Query Performance Validation is instructions for the agent only. Our summary lists: A ClickHouse environment with read-only access, or a Testcontainers dataset to extrapolate from.

Does ClickHouse Query Performance Validation access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is ClickHouse Query Performance Validation 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 Query Performance Validation use?

ClickHouse Query Performance Validation is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does ClickHouse Query Performance Validation use?

About 2.1k tokens (SKILL.md is roughly 8.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to ClickHouse Query Performance Validation?

Skills that share tags, products or a category with ClickHouse Query Performance Validation: Pytorch Clickhouse (pytorch/test-infra, 113 stars), Clickhouse Io (affaan-m/ECC, 274k stars), Generating Clickhouse Query Performance Reports (PostHog/posthog-foss, 721 stars) and Performance (kid-sid/claude-spellbook, 189 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains ClickHouse Query Performance Validation?

comet-ml (a GitHub organization) maintains it in comet-ml/opik, which has 22,412 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on October 7, 2026.

Source: comet-ml/opik on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.