SQL Pro
Jeffallan/claude-skills
Optimizes SQL queries and designs schemas using CTEs, window functions, covering indexes and EXPLAIN ANALYZE, with notes on dialect differences between major databases.
Execute use when you need to work with query optimization. An agent skill from jeremylongshore/tons-of-skills-marketplace.
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-sql-queries -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install jeremylongshore/tons-of-skills-marketplace optimizing-sql-queries --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/optimizing-sql-queries .claude/skills/optimizing-sql-queries && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "optimizing-sql-queries" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/skills/.curated/optimizing-sql-queries into .claude/skills/optimizing-sql-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql-queries", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/skills/.curated/optimizing-sql-queriesType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-sql-queries -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install jeremylongshore/tons-of-skills-marketplace optimizing-sql-queries --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/.curated/optimizing-sql-queries .agents/skills/optimizing-sql-queries && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "optimizing-sql-queries" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/skills/.curated/optimizing-sql-queries into .agents/skills/optimizing-sql-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql-queries", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-sql-queries -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install jeremylongshore/tons-of-skills-marketplace optimizing-sql-queries --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/.curated/optimizing-sql-queries .cursor/skills/optimizing-sql-queries && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "optimizing-sql-queries" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/skills/.curated/optimizing-sql-queries into .cursor/skills/optimizing-sql-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql-queries", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/jeremylongshore/tons-of-skills-marketplace.git --path skills/.curated/optimizing-sql-queries--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-sql-queries -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install jeremylongshore/tons-of-skills-marketplace optimizing-sql-queries --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/.curated/optimizing-sql-queries .gemini/skills/optimizing-sql-queries && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "optimizing-sql-queries" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/skills/.curated/optimizing-sql-queries into .gemini/skills/optimizing-sql-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql-queries", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install jeremylongshore/tons-of-skills-marketplace optimizing-sql-queriesInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-sql-queries -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/.curated/optimizing-sql-queries .github/skills/optimizing-sql-queries && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "optimizing-sql-queries" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/skills/.curated/optimizing-sql-queries into .github/skills/optimizing-sql-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql-queries", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-sql-queries -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install jeremylongshore/tons-of-skills-marketplace optimizing-sql-queries --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/.curated/optimizing-sql-queries .opencode/skills/optimizing-sql-queries && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "optimizing-sql-queries" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/skills/.curated/optimizing-sql-queries into .opencode/skills/optimizing-sql-queries/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql-queries", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
optimizing-sql-queriesExecute use when you need to work with query optimization. An agent skill from jeremylongshore/tons-of-skills-marketplace.
Optimizing SQL Queries is an agent skill from jeremylongshore/tons-of-skills-marketplace. Execute use when you need to work with query optimization. This skill provides query performance analysis with comprehensive guidance and automation. Trigger with phrases like "optimize queries", "analyze performance", or "improve query speed".
Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 8 other files, including scripts, reference files and assets (for example `assets/README.md`, `references/README.md` and `scripts/README.md`). Compatibility notes: Designed for Claude Code
It sits in Databases, covering Query optimization and SQL. It works with SQL, PostgreSQL and MySQL. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.
10 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 23ea8d4. It shows what the files ask for, not the result of running them.
Pre-approves these tools, so the agent can use them without asking each time:
ReadWriteEditGrepGlobBash(psql:*)Bash(mysql:*)Bash(mongosh:*)From allowed-tools in the SKILL.md frontmatter.
Ships 3 files in scripts/ (Python), which the agent can run.
From the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
postgresql.orguse-the-index-luke.commodern-sql.comFrom URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Designed for Claude Code
From compatibility in the SKILL.md frontmatter.
Optimizing SQL Queries loads about 1.7k tokens when it runs, and up to ~1.8k if it reads all its reference files. Until then it costs about 67 tokens; SKILL.md has 844 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.
The full file from jeremylongshore/tons-of-skills-marketplace at commit 23ea8d4, republished under its MIT licence (© jeremylongshore). 844 words, ~1,747 tokens.
.claude/skills/optimizing-sql-queries/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.Rewrite SQL queries for maximum performance by eliminating anti-patterns, restructuring JOINs, leveraging window functions, and applying database-specific optimizations for PostgreSQL and MySQL. This skill takes a slow query and its execution plan as input and produces an optimized version with measurable improvement, along with any supporting index changes needed.
EXPLAIN ANALYZE output (PostgreSQL) or EXPLAIN FORMAT=JSON output (MySQL) for the querypsql or mysql CLI for testing rewritesExamine the original query structure and identify common anti-patterns:
SELECT * instead of specific columns (forces unnecessary I/O)WHERE column IN (SELECT ...) that can be rewritten as JOIN or EXISTSDISTINCT used to mask duplicate rows from incorrect JOINsWHERE UPPER(name) = 'FOO')OR conditions that prevent index usageNOT IN with nullable columns (produces wrong results and poor plans)Analyze the execution plan to identify the most expensive operation nodes. Focus optimization effort on the node consuming the most time or processing the most rows.
Rewrite subqueries as JOINs where possible. Convert correlated subqueries to lateral joins (PostgreSQL) or derived tables. Replace IN (SELECT ...) with EXISTS (SELECT 1 ...) for existence checks since EXISTS short-circuits after the first match.
Optimize JOIN ordering for the query planner: place the most selective table (fewest matching rows after WHERE filters) as the driving table. Use JOIN hints only as a last resort since the optimizer usually picks the correct order with accurate statistics.
Replace multiple OR conditions on the same column with IN (...): change WHERE status = 'active' OR status = 'pending' to WHERE status IN ('active', 'pending'). For OR across different columns, consider UNION ALL of two simpler queries.
Apply window functions to replace self-joins or correlated subqueries. Use ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...) for top-N-per-group queries instead of GROUP BY with subqueries.
Leverage CTEs (Common Table Expressions) for readability but be aware that PostgreSQL versions before 12 materialize all CTEs. For performance-critical queries on older PostgreSQL, inline the CTE as a subquery.
Optimize aggregation queries by filtering before grouping (WHERE is more efficient than HAVING for non-aggregate conditions), using partial indexes for filtered aggregates, and considering materialized views for expensive recurring aggregations.
Test the rewritten query with EXPLAIN ANALYZE and compare execution time, row estimates vs. actuals, and buffer usage against the original. The optimized version should show fewer rows processed, index scans replacing sequential scans, and lower total execution time.
Document each change made, the reason for the change, and the measured impact so the development team understands and can apply similar patterns to future queries.
| Error | Cause | Solution |
|---|---|---|
| Rewritten query returns different results | JOIN type change (INNER vs LEFT) or NULL handling difference | Verify result sets match with EXCEPT query; preserve original JOIN types; handle NULLs explicitly with COALESCE |
| Optimized query slower than original | Statistics outdated causing planner to choose wrong plan | Run ANALYZE on involved tables; compare estimated rows vs actual rows in EXPLAIN; consider SET enable_seqscan = off to test alternative plans |
| CTE materialization hurting performance | PostgreSQL <12 materializes CTEs preventing predicate pushdown | Inline the CTE as a subquery; upgrade PostgreSQL; add AS NOT MATERIALIZED hint in PostgreSQL 12+ |
| Window function query uses excessive memory | Large partition sizes with ORDER BY in window specification | Add LIMIT to outer query; use index matching the PARTITION BY and ORDER BY columns; increase work_mem for the session |
| UNION ALL produces duplicates | Overlapping conditions in constituent queries | Add mutually exclusive WHERE conditions to each branch; or use UNION (with dedup cost) if overlap is unavoidable |
Converting correlated subquery to JOIN: Original: SELECT * FROM orders WHERE customer_id IN (SELECT id FROM customers WHERE region = 'US') taking 8 seconds with sequential scan on orders. Rewrite: SELECT o.* FROM orders o JOIN customers c ON o.customer_id = c.id WHERE c.region = 'US' using index on orders.customer_id reduces to 120ms.
Top-N per group with window function: Original uses self-join to find the 3 most recent orders per customer (15 seconds). Rewrite: SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY created_at DESC) AS rn FROM orders) sub WHERE rn <= 3 with index on (customer_id, created_at DESC) completes in 400ms.
Eliminating DISTINCT from incorrect JOIN: SELECT DISTINCT o.* FROM orders o JOIN line_items li ON o.id = li.order_id WHERE li.amount > 100 scans all line items. Rewrite: SELECT o.* FROM orders o WHERE EXISTS (SELECT 1 FROM line_items li WHERE li.order_id = o.id AND li.amount > 100) eliminates the deduplication step and halves execution time.
© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 5 other files (scripts, references, assets) in skills/.curated/optimizing-sql-queries of jeremylongshore/tons-of-skills-marketplace.
Open the folder on GitHubat commit 23ea8d4
Optimizing SQL Queries next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Optimizing SQL Queries this skilljeremylongshore/tons-of-skills-marketplace | 2.8k | — | ~1.7k | Automated safety check: Pass | MIT | |
| SQL ProJeffallan/claude-skills | 12k | — | ~1.3k | Automated safety check: Pass | MIT | |
| SQL Optimizationgithub/awesome-copilot | 40k | 2 repos | ~2.3k | Automated safety check: Pass | MIT | |
| Query Expertjamesrochabrun/skills | 216 | — | ~4.3k | Automated safety check: Pass | MIT | |
| Optimizing SQLancoleman/ai-design-components | 526 | — | ~3k | Automated safety check: Pass | MIT | |
| Dsqlawslabs/agent-plugins | 915 | — | ~6.9k | Automated safety check: Pass | Apache-2.0 |
Jeffallan/claude-skills
Optimizes SQL queries and designs schemas using CTEs, window functions, covering indexes and EXPLAIN ANALYZE, with notes on dialect differences between major databases.
github/awesome-copilot
Universal SQL performance optimization assistant for comprehensive query tuning, indexing strategies, and database performance analysis across all SQL databases (MySQL, PostgreSQL, SQL Server…
jamesrochabrun/skills
Master SQL and database queries across multiple systems. An agent skill from jamesrochabrun/skills.
ancoleman/ai-design-components
Optimize SQL query performance through EXPLAIN analysis, indexing strategies, and query rewriting for PostgreSQL, MySQL, and SQL Server.
awslabs/agent-plugins
Build with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, diagnose cluster performance, load data, and develop applications with a serverless, distributed…
xiaoyuge886/aigc
Expert SQL developer specializing in complex query optimization, database design, and performance tuning across PostgreSQL, MySQL, SQL Server, and Oracle.
jeremylongshore/tons-of-skills-marketplace
Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.
jeremylongshore/tons-of-skills-marketplace
Execute this skill enables AI assistant to perform natural language processing and text analysis using the nlp-text-analyzer plugin.
jeremylongshore/tons-of-skills-marketplace
Execute this skill allows AI assistant to construct and configure neural network architectures using the neural-network-builder plugin.
jeremylongshore/tons-of-skills-marketplace
Process identify anomalies and outliers in datasets using machine learning algorithms.
jeremylongshore/tons-of-skills-marketplace
Build this skill enables AI assistant to provide interpretability and explainability for machine learning models.
jeremylongshore/tons-of-skills-marketplace
Execute this skill optimizes prompts for large language models (llms) to reduce token usage, lower costs, and improve performance.
Works with
Categories
Execute use when you need to work with query optimization. An agent skill from jeremylongshore/tons-of-skills-marketplace. Optimizing SQL Queries is an agent skill from jeremylongshore/tons-of-skills-marketplace. Execute use when you need to work with query optimization.
Optimizing SQL Queries fits situations like: you need to work with query optimization; with phrases like optimize queries; analyze performance; improve query speed.
Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-sql-queries -a claude-code`. Or copy the skill folder (skills/.curated/optimizing-sql-queries in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/optimizing-sql-queries in your project. Claude Code loads it when a task matches its description.
Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-sql-queries -a codex`. Or copy the skill folder (skills/.curated/optimizing-sql-queries in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/optimizing-sql-queries in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-sql-queries -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/optimizing-sql-queries, .gemini/skills/optimizing-sql-queries, .github/skills/optimizing-sql-queries and .opencode/skills/optimizing-sql-queries in your project.
Going by SKILL.md and its folder, Optimizing SQL Queries needs Python for the scripts in its folder. Our summary lists: Python 3. Its frontmatter pre-approves these tools: Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*), Bash(mongosh:*). Compatibility (from SKILL.md): Designed for Claude Code.
SKILL.md names 3 domains. As links in the text: postgresql.org, use-the-index-luke.com and modern-sql.com. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.
Optimizing SQL Queries is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 1.7k tokens (SKILL.md is roughly 7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 16 tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Optimizing SQL Queries: SQL Pro (Jeffallan/claude-skills, 12k stars), SQL Optimization (github/awesome-copilot, 40k stars), Query Expert (jamesrochabrun/skills, 216 stars) and Optimizing SQL (ancoleman/ai-design-components, 526 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,821 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 8, 2026.
Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.