sql-query-optimization

sql-query-optimization is a skill for Claude Code, Codex from jggomez/expert-ai-developer-skills. It costs 87 tokens per session (1,221 once invoked), scanned A, original, Apache-2.0.

Diagnoses and rewrites slow SQL on traditional engines (Postgres, MySQL, SQL Server, etc.) using EXPLAIN/EXPLAIN ANALYZE — indexing strategy, WHERE clause selectivity, avoiding functions on indexed columns, JOIN vs. subquery vs. CTE tradeoffs, and pagination. Use for any query slowness outside BigQuery, or when a…

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Claude Code; mentions AGENTS.md.

Install with agentmods
npx agentmods add skills/jggomez/expert-ai-developer-skills/sql-query-optimization
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add jggomez/expert-ai-developer-skills --skill sql-query-optimization
Clone the repo
git clone --depth 1 https://github.com/jggomez/expert-ai-developer-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for sql-query-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/jggomez/expert-ai-developer-skills/sql-query-optimization/github.svg)](https://agentmods.dev/skills/jggomez/expert-ai-developer-skills/sql-query-optimization)
Your own site
<a href="https://agentmods.dev/skills/jggomez/expert-ai-developer-skills/sql-query-optimization"><img src="https://agentmods.dev/badge/skills/jggomez/expert-ai-developer-skills/sql-query-optimization/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for sql-query-optimization

Your own site · 80×15
<a href="https://agentmods.dev/skills/jggomez/expert-ai-developer-skills/sql-query-optimization"><img src="https://agentmods.dev/badge/skills/jggomez/expert-ai-developer-skills/sql-query-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 87 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,221 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00087 $0.01221
Opus 5.5 $0.00035 $0.00488
Sonnet 5.5 $0.00017 $0.00244
Haiku 4.5 $0.00009 $0.00122

Measured today against content hash cede959f09e4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

sql-query-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/antigravity/sql-query-optimizer/skills/sql-query-optimization/SKILL.md · 57 lines

How it starts

The opening of the file, as written. The whole thing — 57 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SQL Query Optimization Skill

Overview

Diagnoses, profiles, and optimizes slow SQL queries across traditional relational engines (PostgreSQL, MySQL, SQL Server, SQLite, Oracle) under the rule: start from the execution plan, never from intuition. Analyzes EXPLAIN ANALYZE plans, designs selective composite indexes, rewrites non-sargable predicates and deep OFFSET pagination, and enforces concise artifact caps and fail-honest plan reporting.

When to Use

Trigger Scenarios

  • Query latency spikes, timeouts, sequential scan bottlenecks, or high CPU/buffer reads on OLTP RDBMS engines.
  • Analyzing EXPLAIN (ANALYZE, BUFFERS) (Postgres) or EXPLAIN ANALYZE (MySQL/SQL Server) execution trees.
  • Designing composite/covering indexes, unwrapping indexed predicates, and converting OFFSET to keyset pagination.

When NOT to Use

  • Google Cloud BigQuery MPP queries: Route to bigquery-query-optimization.
  • Schema migrations and DDL lock safety: Route to database-migration-expert.
  • Application-layer caching: Route to performance-scalability.

Process

Phase 1: Fail-Honest Execution Plan Diagnostics

  1. Obtain the Live Plan: Run EXPLAIN (ANALYZE, BUFFERS, VERBOSE) <query>; (or read-only EXPLAIN for mutating statements wrapped in BEGIN; ... ROLLBACK;).
  2. Fail-Honest Fallback (STATIC_ANALYSIS_ONLY / BLOCKED): If DB EXPLAIN fails due to missing credentials or an unreachable database, explicitly mark the output STATIC_ANALYSIS_ONLY / BLOCKED: Live plan not executed — <exact error> and NEVER invent row counts, buffer reads, or EXPLAIN ANALYZE latencies.
  3. Locate Bottlenecks: Inspect unexpected Seq Scan nodes, massive estimated-vs-actual row skew (run ANALYZE <table>; if stale), and disk-spilling external sorts/hashes.

Phase 2: Indexing & Query Rewriting Patterns

  1. Composite Index Ordering: Index WHERE, JOIN ... ON, and ORDER BY columns ordered equality predicates first, then range/sort columns; avoid over-indexing write-heavy tables.
  2. Sargable Predicates: Unwrap indexed columns (WHERE created_at >= '2026-09-01' AND created_at < '2026-09-02' instead of WHERE DATE(created_at) = '2026-09-01').
  3. Keyset Pagination & Decorrelation: Replace OFFSET 50000 with WHERE id > :last_seen_id ORDER BY id ASC LIMIT 20; convert correlated subqueries into explicit JOINs; replace SELECT * to enable Index-Only Scans.

Read the full file on GitHub · 57 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 57 lines · 87 tokens per session scan A cede959f09e4

Subscribe to this mod's changes

sql-query-optimization is a skill published in the GitHub repository jggomez/expert-ai-developer-skills (30 stars, last pushed yesterday), licensed Apache-2.0. It adds 87 tokens to every session and 1,221 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-06.

Related

sql-query-optimization compared with skills from other repositories

sql-query-optimization next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
sql-query-optimizationjggomez/expert-ai-developer-skillsSkill30yesterdayApache-2.0A87Claude Code, Codex
reproduce-buggoogleapis/mcp-toolboxSkill17kyesterdayApache-2.0A130Claude Code, Codex
triage-issuesgoogleapis/mcp-toolboxSkill17kyesterdayApache-2.0A164Claude Code, Codex
postgresql-indexingprowler-cloud/prowlerSkill15kyesterdayApache-2.0A108Claude Code
graphjin-evaldosco/graphjinSkill3.2k5d agoApache-2.0A27Claude Code, Codex
axiom-audit-grdb-performanceCharlesWiltgen/AxiomSkill1.3kyesterdayMITA43Codex
django-perf-reviewgetsentry/skillsSkill1.1kyesterdayApache-2.0A55Claude Code