Skip to content
github/awesome-copilot

SQL Database Query Performance Optimization Assistant

GitHub CopilotGemini CLIClaude CodeOpenAI CodexCursorDevin / Windsurf

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.
Start here

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
  1. Create this path inside your project if it does not exist:.github/skills/
  2. Copy the entire extracted skill folder to this path:.github/skills/sql-optimization/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for sql-optimization.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide GitHub Copilot official documentation ↗
Gemini CLI
  1. Create this path inside your project if it does not exist:.gemini/skills/
  2. Copy the entire extracted skill folder to this path:.gemini/skills/sql-optimization/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for sql-optimization.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide Gemini CLI official documentation ↗
Claude Code
  1. Create this path inside your project if it does not exist:.claude/skills/
  2. Copy the entire extracted skill folder to this path:.claude/skills/sql-optimization/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for sql-optimization.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide Claude Code official documentation ↗
OpenAI Codex
  1. Create this path inside your project if it does not exist:.agents/skills/
  2. Copy the entire extracted skill folder to this path:.agents/skills/sql-optimization/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for sql-optimization.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide OpenAI Codex official documentation ↗
Cursor
  1. Create this path inside your project if it does not exist:.cursor/skills/
  2. Copy the entire extracted skill folder to this path:.cursor/skills/sql-optimization/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for sql-optimization.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide Cursor official documentation ↗
Devin / Windsurf
  1. Create this path inside your project if it does not exist:.devin/skills/
  2. Copy the entire extracted skill folder to this path:.devin/skills/sql-optimization/SKILL.md
  3. Open the project in your agent or refresh the skills list and look for sql-optimization.
  4. Request the task shown above and select the skill. Grant only necessary permissions.
Guide Devin / Windsurf official documentation ↗

Original files retain their language to preserve tool names and paths. Compatibility is classified by review, not runtime testing on every agent version.