Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Analyzes and optimizes SQL queries across different data warehouse platforms (Snowflake, BigQuery, Redshift, Databricks) with platform-specific recommendations.
.claude/skills/a5c-ai-sql-query-optimizer/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 113% | 0% |
| case-17 | ✗→✓ | ▲ Improved | 145% | 0% |
| case-01 | ✗→✓ | ▲ Improved | 108% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 51% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 42% | 0% |
Analyzes and optimizes SQL queries across different data warehouse platforms with platform-specific recommendations.
This skill examines SQL queries to identify performance bottlenecks, suggest optimizations, and provide platform-specific recommendations for Snowflake, BigQuery, Redshift, and Databricks. It analyzes query execution plans, recommends indexes/clustering keys, and identifies anti-patterns.
json{ "query": { "type": "string", "description": "The SQL query to analyze", "required": true }, "platform": { "type": "string", "enum": ["snowflake", "bigquery", "redshift", "databricks", "postgres"], "required": true, "description": "Target data warehouse platform" }, "tableStatistics": { "type": "object", "description": "Table statistics including row counts, column cardinality", "properties": { "tables": { "type": "array", "items": { "name": "string", "rowCount": "number", "sizeGB": "number", "columns": "array" } } } }, "executionPlan": { "type": "object", "description": "Query execution plan (EXPLAIN output)" }, "queryHistory": { "type": "object", "description": "Historical query performance metrics" }, "optimizationGoals": { "type": "array", "items": { "type": "string", "enum": ["latency", "cost", "throughput", "scan_reduction"] }, "default": ["latency", "cost"] } }
json{ "optimizedQuery": { "type": "string", "description": "The optimized SQL query" }, "improvements": { "type": "array", "items": { "type": { "type": "string", "enum": ["join", "predicate", "aggregation", "cte", "window", "scan", "index"] }, "description": "string", "impact": "high|medium|low", "lineNumber": "number", "originalCode": "string", "optimizedCode": "string" } }, "indexRecommendations": { "type": "array", "items": { "table": "string", "type": "clustering|sort|partition|index", "columns": "array", "rationale": "string", "ddl": "string" } }, "estimatedImprovement": { "scanReduction": { "type": "number", "description": "Percentage reduction in data scanned" }, "timeReduction": { "type": "number", "description": "Percentage reduction in execution time" }, "costReduction": { "type": "number", "description": "Percentage reduction in query cost" } }, "antiPatterns": { "type": "array", "items": { "pattern": "string", "severity": "high|medium|low", "location": "string", "suggestion": "string" } }, "platformSpecificNotes": { "type": "array", "items": "string" } }
json{ "query": "SELECT * FROM orders o JOIN customers c ON o.customer_id = c.id WHERE o.created_at > '2024-01-01'", "platform": "snowflake" }
json{ "query": "SELECT customer_id, SUM(amount) FROM orders GROUP BY customer_id", "platform": "bigquery", "executionPlan": { "stages": [...], "totalBytesProcessed": 1073741824 }, "optimizationGoals": ["cost", "scan_reduction"] }
json{ "query": "SELECT ... complex query ...", "platform": "redshift", "tableStatistics": { "tables": [ { "name": "orders", "rowCount": 10000000, "sizeGB": 50, "columns": [ {"name": "order_id", "cardinality": 10000000}, {"name": "customer_id", "cardinality": 500000} ] } ] } }
| Optimization | Description | |--------------|-------------| | Clustering keys | Recommend micro-partition clustering | | Result cache | Identify queries benefiting from caching | | Query acceleration | Suggest QUERY_ACCELERATION_MAX_SCALE_FACTOR | | Warehouse sizing | Right-size warehouse recommendations |
| Optimization | Description | |--------------|-------------| | Partitioning | DATE/TIMESTAMP partitioning recommendations | | Clustering | Up to 4 clustering columns | | BI Engine | Identify BI Engine-eligible queries | | Slots | Estimate slot usage optimization |
| Optimization | Description | |--------------|-------------| | Sort keys | COMPOUND vs INTERLEAVED recommendations | | Distribution | KEY, EVEN, ALL distribution strategies | | Compression | Column encoding recommendations | | Vacuum | VACUUM and ANALYZE recommendations |
| Optimization | Description | |--------------|-------------| | Z-ordering | Multi-column Z-order recommendations | | Delta cache | Caching strategy recommendations | | Photon | Photon-eligible query patterns | | Adaptive execution | AQE configuration suggestions |
| Anti-Pattern | Impact | Fix | |--------------|--------|-----| | SELECT | High | Specify columns explicitly | | Correlated subqueries | High | Convert to JOIN or CTE | | DISTINCT on large datasets | Medium | Use GROUP BY or window functions | | Non-SARGable predicates | High | Rewrite for index usage |
| Anti-Pattern | Impact | Fix | |--------------|--------|-----| | Cartesian products | Critical | Add join conditions | | Implicit joins | Medium | Use explicit JOIN syntax | | Wrong join order | High | Reorder by selectivity | | Missing indexes on join keys | High | Add clustering/sort keys |
| Anti-Pattern | Impact | Fix | |--------------|--------|-----| | GROUP BY ordinal | Low | Use column names | | Aggregating before filter | High | Filter first, then aggregate | | Over-grouping | Medium | Reduce GROUP BY columns |
query-optimization.js)data-warehouse-setup.js)bi-dashboard.js)obt-creation.js)| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | fail→pass | 13,237 | 15,237 | +15% | 1 | 1 | 0% | 2,471 | 5,253 | +113% | 0 | 0 | — |
case-17 | fail→pass | 8,905 | 13,466 | +51% | 1 | 1 | 0% | 1,672 | 4,103 | +145% | 0 | 0 | — |
case-01 | fail→pass | 10,417 | 10,538 | +1% | 1 | 1 | 0% | 2,199 | 4,570 | +108% | 0 | 0 | — |
case-03 | fail→pass | 16,647 | 13,100 | -21% | 1 | 1 | 0% | 3,083 | 4,654 | +51% | 0 | 0 | — |
case-04 | pass→pass | 6,153 | 5,858 | -5% | 1 | 1 | 0% | 1,209 | 3,241 | +168% | 0 | 0 | — |
case-05 | pass→pass | 12,744 | 16,115 | +26% | 1 | 1 | 0% | 2,976 | 5,828 | +96% | 0 | 0 | — |
case-06 | pass→pass | 8,863 | 7,503 | -15% | 1 | 1 | 0% | 1,829 | 3,568 | +95% | 0 | 0 | — |
case-07 | fail→fail | 10,622 | 9,700 | -9% | 1 | 1 | 0% | 2,159 | 4,337 | +101% | 0 | 0 | — |
case-08 | fail→pass | 10,664 | 6,607 | -38% | 1 | 1 | 0% | 2,403 | 3,416 | +42% | 0 | 0 | — |
case-09 | fail→pass | 9,487 | 12,916 | +36% | 1 | 1 | 0% | 1,921 | 4,788 | +149% | 0 | 0 | — |
case-10 | fail→pass | 12,977 | 7,962 | -39% | 1 | 1 | 0% | 2,402 | 3,621 | +51% | 0 | 0 | — |
case-11 | fail→pass | 9,594 | 13,376 | +39% | 1 | 1 | 0% | 2,014 | 4,867 | +142% | 0 | 0 | — |
case-18 | fail→pass | 10,568 | 10,616 | +0% | 1 | 1 | 0% | 2,037 | 4,286 | +110% | 0 | 0 | — |
case-12 | fail→pass | 9,709 | 6,402 | -34% | 1 | 1 | 0% | 1,523 | 3,349 | +120% | 0 | 0 | — |
case-13 | fail→fail | 8,408 | 11,013 | +31% | 1 | 1 | 0% | 1,631 | 4,237 | +160% | 0 | 0 | — |
case-14 | fail→fail | 11,245 | 9,419 | -16% | 1 | 1 | 0% | 2,208 | 3,948 | +79% | 0 | 0 | — |
case-15 | fail→pass | 9,246 | 12,888 | +39% | 1 | 1 | 0% | 1,955 | 4,890 | +150% | 0 | 0 | — |
case-16 | fail→pass | 5,915 | 7,996 | +35% | 1 | 1 | 0% | 1,205 | 3,814 | +217% | 0 | 0 | — |
case-19 | fail→pass | 7,462 | 12,399 | +66% | 1 | 1 | 0% | 1,583 | 4,643 | +193% | 0 | 0 | — |
case-20 | fail→pass | 10,139 | 8,775 | -13% | 1 | 1 | 0% | 2,097 | 3,888 | +85% | 0 | 0 | — |
case-21 | fail→pass | 10,399 | 8,292 | -20% | 1 | 1 | 0% | 2,151 | 3,729 | +73% | 0 | 0 | — |
case-22 | fail→pass | 10,329 | 10,828 | +5% | 1 | 1 | 0% | 1,987 | 4,498 | +126% | 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. 22 cases were attempted. The headline lift of +73 percentage points is the difference between those two pass rates over the 22 comparable cases.
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.