sql-optimization-patterns
Helps your agent find problems with slow SQL queries. It checks query plans and index changes to ensure everything runs smoothly.
What it does
This tool helps find and fix issues that make your database queries slow. It analyzes how the database executes your commands and suggests improvements, like adding indexes or rewriting queries, to make everything run faster.
When to use it
- ✓When a database query is taking too long to respond.
- ✓When designing or adjusting the database structure for better performance.
- ✓To understand why the database is overloaded and how to reduce that load.
Example of what to ask your AI
“My SQL query to fetch users is very slow, can you help me optimize it?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The tool analyzes your query's 'execution plan,' which is how the database decides to run the command. Based on this, it suggests changes, like adding indexes or rewriting the query, to make it more efficient.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill sql-optimization-patternsOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/sql-optimization-patterns/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
SQL Optimization Patterns
Diagnose slow SQL with query plans, preserve query results, and verify indexing or query changes against representative data.
Use this skill when
- Debugging slow-running queries
- Designing performant database schemas
- Optimizing application response times
- Reducing database load and costs
- Improving scalability for growing datasets
- Analyzing EXPLAIN query plans
- Implementing efficient indexes
- Resolving N+1 query problems
Do not use this skill when
- The task is unrelated to sql optimization patterns
- You need a different domain or tool outside this scope
Instructions
- Confirm database engine/version, query parameters, expected rows, data distribution and the permitted environment. Start read-only; obtain authorization before DDL, data changes, configuration changes or maintenance.
- Compare result sets before comparing performance. EXPLAIN ANALYZE executes the statement: use approved representative data, account for functions and triggers, and do not assume a transaction rollback undoes every side effect.
- Record the observed plan, timing conditions and correctness checks. Indexes and query rewrites are hypotheses, not universal speed improvements.
- If detailed examples are required, open
resources/implementation-playbook.md.
Resources
resources/implementation-playbook.mdfor detailed patterns and examples.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Worked example
The playbook includes an executable SQLite batch-loading example with bound values and an empty-input case. The repository test exercises it alongside pagination ties and aggregation equivalence. SQLite correctness checks do not establish PostgreSQL performance or production safety.
FAQ
What is an 'execution plan'?
It's the path the database chooses to find and return the data you requested. Analyzing it helps see where the bottlenecks are.
What are 'indexes'?
They are like the index in a book. They help the database find specific information much faster, without having to read everything.
Will the tool change my database?
Not directly. It suggests changes and asks for your authorization before making any modifications, starting with read-only analyses.
Details
Original description by the author
Diagnose slow SQL with query plans, preserve query results, and verify indexing or query changes against representative data.
Popularity
- GitHub stars
- 48k
- Ranking position
- #4231
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
benchmark-optimization-loop
Has your agent improve something's speed in a measured way. It tests multiple versions and chooses the fastest one that still works correctly.
affaan-m/ECC
change-impact
Helps your agent analyze the impact of code changes before making them. It compares the planned vs. actual results afterward, covering paths, data, tests, and documentation. Useful for risky or system-wide changes.
affaan-m/ECC
click-path-audit
Lets your agent trace all user buttons and interactions to find bugs. It finds issues where functions seem to work alone but fail together. Useful when bugs persist even after debugging.
affaan-m/ECC