SQL Query Rewriter

Rewrites a structurally inefficient SQL query into a faster equivalent that returns identical results - correlated subqueries to joins or LATERAL, accidental cross joins to explicit ON predicates, OR-across-columns to UNION, SELECT * to projected columns, and deep OFFSET pagination to keyset. Use when a query is slow because of its shape rather than its indexes - EXPLAIN shows a Cartesian blowup, a per-row subquery, or OFFSET discarding tens of thousands of rows - and the indexes are already in place. Do NOT use when the fix is adding or reordering an index - use index-advisor instead; do NOT use to diagnose an unknown slow query from its plan - use sql-query-optimizer instead.

SkillMedev 291150d 6.3 KB Updated

File contents

SkillMedev/database-performance/tree/main/skills/query-rewriter commit 291150d933

Frequently asked questions

npx skillmds@latest add skillmedev/sql-query-rewriter