github/awesome-copilot
SQL Database Query Performance Optimization Assistant
About this skill
A comprehensive guide to optimizing SQL query performance in general, working with MySQL, PostgreSQL, SQL Server, and Oracle. It covers execution plan analysis, composite, partial, and covering indexing strategies, subquery optimization using window functions, join and cursor-based pagination optimization, and batch operations, along with performance monitoring queries to detect slow queries and a systematic optimization checklist.
How do you use this skill?
1. Identify the slow query or set of queries you want to optimize within your project.
2. Ask the agent to analyze the query according to the file's methodology: identify the problem, examine the execution plan, then apply the appropriate optimization techniques.
3. Replace bad patterns such as SELECT *, functions inside WHERE, and correlated subqueries with improved patterns such as explicitly specifying columns and window functions.
4. Request suggestions for composite, partial, or covering indexes suitable for your query patterns.
5. Apply additional optimizations such as cursor-based pagination, batch operations, and conditional aggregation in a single query.
6. Example user request: "This query takes a long time on the orders table which contains millions of rows, how do I optimize it? SELECT * FROM orders WHERE YEAR(created_at) = 2024 AND customer_id IN (SELECT id FROM customers WHERE status = 'active')"
Requirements and limitations
The file does not require tools or external accounts; it is a text guide to SQL optimization techniques. It assumes the availability of an SQL database (such as MySQL, PostgreSQL, SQL Server, or Oracle) and familiarity with execution plans and your engine's slow query monitoring tools. Some of the syntax included is specific to particular engines (such as INCLUDE for SQL Server and partial indexes for PostgreSQL) and may need adaptation depending on your database. Changes to production databases should be tested with realistic data volumes before adoption.
Installation by agent
Download and extract the ZIP. It contains the folder sql-optimization and the file SKILL.md with the original attachments and license.
GitHub Copilot
- Create this path inside your project if it does not exist:
.github/skills/ - Copy the entire extracted skill folder to this path:
.github/skills/sql-optimization/SKILL.md - Open the project in your agent or refresh the skills list and look for sql-optimization.
- Request the task shown above and select the skill. Grant only necessary permissions.
Gemini CLI
- Create this path inside your project if it does not exist:
.gemini/skills/ - Copy the entire extracted skill folder to this path:
.gemini/skills/sql-optimization/SKILL.md - Open the project in your agent or refresh the skills list and look for sql-optimization.
- Request the task shown above and select the skill. Grant only necessary permissions.
Claude Code
- Create this path inside your project if it does not exist:
.claude/skills/ - Copy the entire extracted skill folder to this path:
.claude/skills/sql-optimization/SKILL.md - Open the project in your agent or refresh the skills list and look for sql-optimization.
- Request the task shown above and select the skill. Grant only necessary permissions.
OpenAI Codex
- Create this path inside your project if it does not exist:
.agents/skills/ - Copy the entire extracted skill folder to this path:
.agents/skills/sql-optimization/SKILL.md - Open the project in your agent or refresh the skills list and look for sql-optimization.
- Request the task shown above and select the skill. Grant only necessary permissions.
Cursor
- Create this path inside your project if it does not exist:
.cursor/skills/ - Copy the entire extracted skill folder to this path:
.cursor/skills/sql-optimization/SKILL.md - Open the project in your agent or refresh the skills list and look for sql-optimization.
- Request the task shown above and select the skill. Grant only necessary permissions.
Devin / Windsurf
- Create this path inside your project if it does not exist:
.devin/skills/ - Copy the entire extracted skill folder to this path:
.devin/skills/sql-optimization/SKILL.md - Open the project in your agent or refresh the skills list and look for sql-optimization.
- Request the task shown above and select the skill. Grant only necessary permissions.