Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Optimize slow queries, analyze SQL performance, and collect evidence for expensive workloads.
.claude/skills/frankchen021-optimize-clickhouse-sql/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-12 | ✗→✓ | ▲ Improved | 63% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 3% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 51% | 0% |
| case-20 | ✗→✓ | ▲ Improved | 34% | 0% |
| case-04 | ✓→✗ | ▼ Worse | 20% | 0% |
Workflow is evidence-driven: collect evidence with tools, then recommend based on evidence only.
collect_sql_optimization_evidence immediately).ask_user_question with exactly one question:header: Please provide one of the following for optimizationoptions:{ "id": "sql", "label": "Provide SQL", "input": "text" }{ "id": "query_id", "label": "Provide query_id", "input": "text" }{ "id": "resource", "label": "Find the query that consumes the most", "input": "select", "choices": ["duration", "cpu", "memory", "disk"] }After the tool returns:
optionId is sql, treat value as the SQL text and continue with evidence collection.optionId is query_id, treat value as the query_id and continue with evidence collection.optionId is resource, treat value as the ranking metric and run discovery for the top 1 query in the last 1 day before continuing.search_query_log for discovery from system.query_log (slowest, most expensive, user-scoped, database-scoped, text-scoped, etc.).search_query_log cannot express the request, then load the clickhouse-system-queries skill, immediately call skill_resource for references/system-query-log.md, and follow that reference strictly.system.query_log from this skill when search_query_log can satisfy the request.query_id from the discovery results for the next step (evidence collection).time_window: Relative minutes from now (e.g., 60 = last hour).time_range: Absolute range { from: "ISO date", to: "ISO date" }.collect_sql_optimization_evidence after discovery, you MUST pass the same time_window or time_range used in discovery.collect_sql_optimization_evidence to light mode for the first pass.mode argument entirely unless full detail is required.mode: "full" only when the user explicitly asks for detailed/raw evidence or the light pass is insufficient.full just because the request says "optimize", "analyze", or "investigate".search_query_log to find candidates. If the request exceeds the tool's schema, then load clickhouse-system-queries, load references/system-query-log.md via skill_resource, and use that reference. Extract query_id from the results.collect_sql_optimization_evidence with query_id (preferred) or sql (and same time params if coming from discovery).validate_sql for any proposed SQL changes. Add inline comments (-- comment) to highlight key changes.optimization_target is present, treat it as the real local-table schema behind a Distributed table and base key/index recommendations on it.minmax for range predicates on sorted columns.set for low-cardinality equality filters.bloom_filter for high-cardinality equality filters (e.g., trace_id, user_id).tokenbf_v1 for frequent token-based text search.validate_sql before recommending.query_id instead of sql.query_id and SQL are available, prefer query_id to reduce tokens and avoid truncation issues.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | fail→fail | 16,727 | 6,044 | -64% | 1 | 1 | 0% | 2,825 | 1,497 | -47% | 0 | 0 | — |
case-12 | fail→pass | 11,791 | 10,031 | -15% | 1 | 1 | 0% | 1,801 | 2,944 | +63% | 0 | 0 | — |
case-01 | fail→fail | 16,218 | 5,712 | -65% | 1 | 1 | 0% | 2,735 | 1,594 | -42% | 0 | 0 | — |
case-03 | fail→fail | 8,215 | 6,168 | -25% | 1 | 1 | 0% | 1,351 | 1,535 | +14% | 0 | 0 | — |
case-04 | pass→fail | 8,489 | 10,575 | +25% | 1 | 1 | 0% | 1,483 | 1,774 | +20% | 0 | 0 | — |
case-05 | pass→pass | 20,502 | 24,377 | +19% | 1 | 1 | 0% | 3,657 | 5,495 | +50% | 0 | 0 | — |
case-06 | pass→pass | 31,012 | 18,155 | -41% | 1 | 1 | 0% | 3,063 | 4,719 | +54% | 0 | 0 | — |
case-07 | fail→fail | 9,236 | 7,873 | -15% | 1 | 1 | 0% | 1,403 | 1,710 | +22% | 0 | 0 | — |
case-08 | pass→fail | 10,861 | 9,845 | -9% | 1 | 1 | 0% | 1,757 | 1,439 | -18% | 0 | 0 | — |
case-09 | pass→fail | 20,755 | 5,389 | -74% | 1 | 1 | 0% | 3,614 | 1,566 | -57% | 0 | 0 | — |
case-10 | fail→pass | 13,003 | 5,752 | -56% | 1 | 1 | 0% | 2,189 | 2,247 | +3% | 0 | 0 | — |
case-11 | pass→pass | 12,081 | 10,828 | -10% | 1 | 1 | 0% | 1,793 | 3,088 | +72% | 0 | 0 | — |
case-13 | fail→pass | 11,599 | 9,112 | -21% | 1 | 1 | 0% | 1,800 | 2,725 | +51% | 0 | 0 | — |
case-14 | pass→pass | 13,021 | 9,106 | -30% | 1 | 1 | 0% | 2,059 | 2,775 | +35% | 0 | 0 | — |
case-15 | pass→pass | 6,177 | 3,311 | -46% | 1 | 1 | 0% | 946 | 1,672 | +77% | 0 | 0 | — |
case-16 | pass→pass | 5,613 | 2,640 | -53% | 1 | 1 | 0% | 967 | 1,651 | +71% | 0 | 0 | — |
case-17 | pass→pass | 9,539 | 3,065 | -68% | 1 | 1 | 0% | 1,535 | 1,672 | +9% | 0 | 0 | — |
case-18 | fail→fail | 5,395 | 2,252 | -58% | 1 | 1 | 0% | 793 | 1,478 | +86% | 0 | 0 | — |
case-19 | pass→pass | 17,326 | 4,094 | -76% | 1 | 1 | 0% | 2,681 | 1,764 | -34% | 0 | 0 | — |
case-20 | fail→pass | 7,351 | 2,695 | -63% | 1 | 1 | 0% | 1,235 | 1,654 | +34% | 0 | 0 | — |
case-21 | pass→pass | 17,085 | 5,612 | -67% | 1 | 1 | 0% | 2,526 | 1,972 | -22% | 0 | 0 | — |
case-22 | pass→pass | 6,534 | 2,209 | -66% | 1 | 1 | 0% | 998 | 1,538 | +54% | 0 | 0 | — |
case-23 | pass→pass | 6,712 | 2,213 | -67% | 1 | 1 | 0% | 1,059 | 1,510 | +43% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted, and 16 counted toward the lift figure. The other 7 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +4 percentage points is the difference between those two pass rates over the 16 comparable cases. 4 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.