data-sql-optimization
Installation
SKILL.md
SQL Optimization
Out of scope: OLAP engines and lakehouse tuning. Use data-lake-platform for ClickHouse, DuckDB, Doris, StarRocks, Iceberg, Delta Lake, or Hudi.
Quick Reference
Scripts
| Script | What it does | Usage |
|---|---|---|
| scripts/pg_slow_query_triage.sql | Six-section triage report from pg_stat_statements: total time, mean time, I/O, variance, cache-hit ratio, and spills/planning/WAL |
Copy-paste into psql or any SQL client; requires pg_stat_statements extension |
| scripts/explain_collector.py | Collects estimated JSON plans via psql; --analyze opts into query execution |
DATABASE_URL=postgresql://... python explain_collector.py --queries slow.txt |
| scripts/test_explain_collector.py | Offline input, execution-mode and JSON-envelope regressions | python scripts/test_explain_collector.py |
# Triage: paste directly into psql
psql "$DATABASE_URL" -f skills/universal/data-sql-optimization/scripts/pg_slow_query_triage.sql