query-optimizer

query-optimizer is a skill for Claude Code from armanzeroeight/fastagent-plugins. It costs 36 tokens per session (2,215 once invoked), scanned A, original, MIT.

Guidance for making SQL database queries run faster. It uses indexes, query rewrites, and execution-plan analysis to find inefficient operations such as scanning unnecessary rows or making repeated queries.

In plain words
What is it for?
Use it to analyse slow SQL, inspect EXPLAIN plans, add suitable indexes, rewrite queries, and investigate repeated database requests.
Why use it?
It helps identify why a query is slow and choose a focused fix. This can reduce wasted database work and avoid common problems such as missing indexes, fetching unused columns, or issuing one query per result.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the database-toolkit plugin — 2 skills shipped together

Good fit Use it to analyse slow SQL, inspect EXPLAIN plans, add suitable indexes, rewrite queries, and investigate repeated database requests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/armanzeroeight/fastagent-plugins/query-optimizer
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 armanzeroeight/fastagent-plugins --skill query-optimizer
Clone the repo
git clone --depth 1 https://github.com/armanzeroeight/fastagent-plugins

Made for: Claude Code.

Or install database-toolkit, the plugin that ships this one along with the rest of its 2 skills.

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 query-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/skills/armanzeroeight/fastagent-plugins/query-optimizer/github.svg)](https://agentmods.dev/skills/armanzeroeight/fastagent-plugins/query-optimizer)
Your own site
<a href="https://agentmods.dev/skills/armanzeroeight/fastagent-plugins/query-optimizer"><img src="https://agentmods.dev/badge/skills/armanzeroeight/fastagent-plugins/query-optimizer/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 query-optimizer

Your own site · 80×15
<a href="https://agentmods.dev/skills/armanzeroeight/fastagent-plugins/query-optimizer"><img src="https://agentmods.dev/badge/skills/armanzeroeight/fastagent-plugins/query-optimizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,215 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00036 $0.02215
Opus 5.5 $0.00014 $0.00886
Sonnet 5.5 $0.00007 $0.00443
Haiku 4.5 $0.00004 $0.00221

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

Security

Grade A, and why

query-optimizer 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 3mo ago.

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/database-toolkit/skills/query-optimizer/SKILL.md · 435 lines

How it starts

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

Query Optimizer

Optimize SQL queries for better performance through indexing, rewriting, and analysis.

Quick Start

Use EXPLAIN to analyze queries, add indexes on WHERE/JOIN columns, avoid SELECT *, limit results.

Instructions

Query Analysis with EXPLAIN

Basic EXPLAIN:

EXPLAIN SELECT * FROM users WHERE email = '[email protected]';

EXPLAIN ANALYZE (actual execution):

EXPLAIN ANALYZE SELECT * FROM users WHERE email = '[email protected]';

Key metrics to check:

  • Seq Scan (bad) vs Index Scan (good)
  • Rows: Estimated vs actual
  • Cost: Lower is better
  • Execution time

Common Performance Issues

1. Missing Indexes

Problem:

-- Seq Scan on users (cost=0.00..1234.56)
SELECT * FROM users WHERE email = '[email protected]';

Solution:

CREATE INDEX idx_users_email ON users(email);
-- Now: Index Scan using idx_users_email

**2. SELECT ***

Problem:

SELECT * FROM posts;  -- Fetches all columns

Solution:

SELECT id, title, created_at FROM posts;  -- Only needed columns

3. N+1 Queries

Problem:

-- Fetches posts
SELECT * FROM posts;
-- Then for each post:
SELECT * FROM users WHERE id = ?;

Solution:

-- Single query with JOIN
SELECT posts.*, users.name 
FROM posts 
JOIN users ON posts.user_id = users.id;

4. No LIMIT

Problem:

SELECT * FROM posts ORDER BY created_at DESC;  -- Returns all rows

Solution:

SELECT * FROM posts ORDER BY created_at DESC LIMIT 20;

Indexing Strategies

Single column index:

CREATE INDEX idx_users_email ON users(email);

Composite index (order matters):

-- For: WHERE user_id = ? AND created_at > ?
CREATE INDEX idx_posts_user_created ON posts(user_id, created_at);

Covering index (includes all needed columns):

-- For: SELECT id, title FROM posts WHERE user_id = ?
CREATE INDEX idx_posts_user_id_title ON posts(user_id) INCLUDE (title);

Partial index (filtered):

CREATE INDEX idx_active_users ON users(email) WHERE is_active = true;

Read the full file on GitHub · 435 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. 3mo ago First seen · 435 lines · 36 tokens per session scan A d16e23bac9c5

Subscribe to this mod's changes

query-optimizer is a skill published in the GitHub repository armanzeroeight/fastagent-plugins (30 stars, last pushed 4mo ago), licensed MIT. It adds 36 tokens to every session and 2,215 once invoked, about $0.0001 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-08-30.

Related

query-optimizer compared with skills from other repositories

query-optimizer next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
query-optimizerarmanzeroeight/fastagent-pluginsSkill304mo agoMITA36Claude Code
bigquery-graphgoogle/adk-pythonSkill22k2d agoApache-2.0A52Claude Code, Codex
bigquery-ai-mlgoogle/adk-pythonSkill22k2d agoApache-2.0A131Claude Code, Codex
ha-data-storesshiwenwen/hope-agentSkill1.9kyesterdayMITA115Claude Code, Codex
dingtalk-ai-tablewecode-ai/WegentSkill895todayApache-2.0A36Claude Code, Codex
sql-styleeverruns/everrunsSkill72todayMITA17Claude Code, Codex
database-operationsmetaspartan/cybaraSkill416d agoMITA22Claude Code, Codex