Install
openclaw skills install sql-optimizationDeep SQL performance workflow—symptom framing, execution plans, indexing strategy, query rewrite, locking/transaction behavior, statistics, partitioning, and verification. Use when queries time out, DB CPU spikes, or migrations change access patterns.
openclaw skills install sql-optimizationOptimization without measurement is guesswork. Structure the work as observe → explain (plan) → change → verify, with explicit attention to correctness, locks, and write amplification from indexes.
Trigger conditions:
Initial offer:
Use six stages: (1) frame the problem, (2) reproduce & measure, (3) read execution plans, (4) schema & indexes, (5) query & transaction tuning, (6) verify & guardrail. Confirm engine (PostgreSQL, MySQL, SQL Server, etc.) and environment (prod-like data volume).
Goal: Define SLO, scope, and non-goals.
Exit condition: One-line problem statement with metric (e.g., “p95 2.4s on /reports at 10k RPS”).
Goal: Stable repro with representative cardinality and parameters.
Exit condition: Baseline numbers + plan hash or saved plan for A/B.
Goal: Name the dominant cost: seq scan, bad join order, sort, hash spill, nested loop explosion.
FOR UPDATE, long transactions, hot row updatesExit condition: Hypothesis tied to plan node(s), not generic “add index.”
Goal: Right indexes for read paths without destroying writes.
ANALYZE, extended stats, histograms—when stale stats lieExit condition: DDL proposal with rationale and rollback (drop index concurrently if supported).
Goal: Sometimes the fix is SQL rewrite, not hardware.
SELECT FOR UPDATEExit condition: New plan shows lower cost / measured latency; lock time acceptable.
Goal: Improvement holds under load and doesn’t regress neighbors.