What problem does it solve?
Slow ClickHouse queries require tedious manual profiling, EXPLAIN analysis, and iterative rewriting. This Skill automates that investigation by running a disciplined optimization campaign on one git branch, systematically testing hypotheses and keeping only validated improvements.
Core Features & Use Cases
- Baseline capture and correctness checking: Captures baseline metrics and result sets, then compares every candidate query against them so faster-but-wrong rewrites are caught automatically.
- Lane and hypothesis management: Organizes optimization ideas into lanes (e.g., index usage, predicate ordering, JSON function choice) with stagnation-aware reviews that decide when to continue, pivot, or close a direction.
- Timeout handling via range narrowing: Halves the query time range until it runs in 1-10 seconds, optimizes there, and escalates back to the full range after each kept win.
- Use Case: A PostHog query runner generates a slow events query. The Skill initializes a workspace, profiles the query with EXPLAIN and system.query_log, tests rewrites like replacing replaceRegexpAll(JSONExtractRaw(...)) with JSONExtractString, and records schema-level suggestions (materialized columns, skip indexes) it cannot apply in the read-only sandbox.
Quick Start
Run a ClickHouse optimization campaign on the slow query in this repository, starting by reading orchestration.md and initializing the .clickhouse-autoresearch workspace.