SQL Query Rewriter

Installation
SKILL.md

SQL Query Rewriter

Reshape a slow query into a faster equivalent that returns identical rows. Shape beats tuning when the query does avoidable work - but a rewrite that changes results is worse than a slow query, so equivalence is proven, never assumed. This skill owns the structural rewrite only: index choice belongs to index-advisor, and plan diagnosis belongs to sql-query-optimizer.

Inputs to collect

  1. The query text and its EXPLAIN (ANALYZE) output - ANALYZE if the query can be run safely, plain EXPLAIN otherwise (label conclusions from estimates as provisional).
  2. Approximate row counts of each table involved, to spot Cartesian blowups.
  3. The existing indexes on the touched tables - a rewrite often assumes a supporting index; confirm it exists or hand off to index-advisor.
  4. What the caller actually consumes: which columns, whether order matters, whether duplicates are possible.
  5. A way to run both versions against the same data for the equivalence diff.

Workflow

Installs
–
GitHub Stars
19
First Seen
–