query-rewriter
Skill2 starsChanged 5 months agoApache-2.0View on GitHub
SQL query rewriting expert. Identifies inefficient query patterns and provides optimized alternatives. Trigger when user mentions query optimization, SQL rewriting, or query performance.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- SkillMedev/database-performancetheir own version, first seen Oct 5, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- SkillMedev/database-performance★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository8 other files it gives its agents.
- cloudflare-auditSkill
- cost-audit-masterSkill
- cost-monitorSkill
- d1-cost-optimizerSkill
- index-optimizerSkill
- redis-auditSkill
- spend-cap-managerSkill
- supabase-auditSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 43
Follow the specific reference file for detailed instructions.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SQL Query Rewriting Expert
Common Anti-Patterns
| Anti-Pattern | Problem | Reference |
| SELECT * | Fetches unnecessary data | references/select-star.md |
| N+1 queries | Too many round trips | references/n-plus-one.md |
| IN with subquery | May process too many rows | references/exists-vs-in.md |
| OR across columns | Prevents index usage | references/or-optimization.md |
| OR conditions | Cannot use index | references/union-instead-of-or.md |
| Type mismatch | Implicit conversion | references/implicit-conversion.md |
Audit Workflow
Step 1: Identify Problem Patterns
Check for:
- SELECT * usage
- N+1 query patterns
- IN with large subqueries
- OR conditions across columns
- Type mismatches
Step 2: Match Anti-Pattern
Identify which anti-pattern the query matches and apply the corresponding solution from the reference file.
Step 3: Apply Rewrite
Follow the specific reference file for detailed instructions.
Step 4: Verify Improvement
EXPLAIN ANALYZE <rewritten_query>;Benchmark Reference
| Optimization | Before | After | Improvement |
| SELECT * → specific | 100ms | 20ms | 80% |
| N+1 → batch | 500ms | 50ms | 90% |
| IN → EXISTS | 500ms | 50ms | 90% |
| OR → UNION | 200ms | 20ms | 90% |
| Type fix | 150ms | 2ms | 98.7% |
Output Format
## Query Rewriting Report
### 1. Original Query
```sql
<original_query>2. Anti-Patterns Detected
| Pattern | Problem | Reference |
| ... | ... | ... |
3. Recommended Rewrite
<optimized_query>4. Expected Improvement
- Query time: Xms → Yms (Z% faster)
- Rows processed: X → Y (Z% reduction)
5. Implementation
Reference: references/<case-name>.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

