nw-query-optimization

nw-query-optimization is a skill for Claude Code from nWave-ai/nWave. It costs 32 tokens per session (1,278 once invoked), scanned A, original, MIT.

Database query optimization guidance for SQL and NoSQL systems. It covers indexes, execution plans, JOIN methods, and database-specific query patterns.

In plain words
What is it for?
Use it to inspect EXPLAIN output, design or improve indexes, compare query plans, and optimize joins and filters.
Why use it?
It helps find why a query is slow and choose changes that reduce unnecessary database work. Execution plans can show whether indexes and statistics are being used effectively.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter.

Good fit Use it to inspect EXPLAIN output, design or improve indexes, compare query plans, and optimize joins and filters.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nwave-ai/nwave/nw-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 nWave-ai/nWave --skill nw-query-optimization
Clone the repo
git clone --depth 1 https://github.com/nWave-ai/nWave

Made for: Claude Code.

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 nw-query-optimization

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/nwave-ai/nwave/nw-query-optimization"><img src="https://agentmods.dev/badge/skills/nwave-ai/nwave/nw-query-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,278 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.00032 $0.01278
Opus 5.5 $0.00013 $0.00511
Sonnet 5.5 $0.00006 $0.00256
Haiku 4.5 $0.00003 $0.00128

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

Security

Grade A, and why

nw-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 2mo 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.

nWave/skills/nw-query-optimization/SKILL.md · 116 lines

How it starts

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

Query Optimization

Cost-Based Optimization

Modern relational DBs use cost-based optimizers (CBO): generate plan candidates -> estimate cost via statistics (row counts, distributions, selectivity) -> select lowest I/O/CPU/memory plan. Stale statistics lead to suboptimal plans.

Execution Plan Analysis

Validate optimization with EXPLAIN before and after changes.

-- PostgreSQL (add ANALYZE for actual runtime stats)
EXPLAIN ANALYZE SELECT order_id, total FROM orders WHERE customer_id = 12345;
-- MySQL: EXPLAIN FORMAT=JSON ... | SQL Server: SET STATISTICS IO ON

Key indicators: Seq Scan/Table Scan = missing index | Index Scan/Seek = efficient | Hash Join = large equality joins | Nested Loop = small/indexed inner | Merge Join = pre-sorted inputs | Sort = watch disk spills

Indexing Strategies

B-Tree (Default)

Supports: equality, range, sorting, prefix matching | O(log n) lookup | General-purpose, all major DBs default

Hash

Equality only | O(1) lookup | High-cardinality exact-match | No range/sorting/pattern support

Covering Indexes

Include all query columns in index -> eliminates table access (index-only scan) | Trade-off: larger index, slower writes

-- Covering index for: SELECT name, email FROM users WHERE status = 'active'
CREATE INDEX idx_users_status_covering ON users(status) INCLUDE (name, email);

PostgreSQL Specialized

  • GiST: Geometric data, full-text search, nearest-neighbor
  • GIN: Arrays, full-text search, JSONB queries
  • BRIN: Large tables with physically correlated data (timestamps), minimal storage
  • SP-GiST: Non-balanced structures, point-based geometric queries

Compound Index Design

Order by: 1. Equality conditions first (highest selectivity) | 2. Sort columns second | 3. Range conditions last

MongoDB ESR Rule

Equality-Sort-Range ordering for compound indexes:

// Query: status = "A", qty > 20, sorted by item
// Optimal index:
db.collection.createIndex({ status: 1, item: 1, qty: 1 })
//                          E(quality)  S(ort)   R(ange)

Read the full file on GitHub · 116 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. 2mo ago First seen · 116 lines · 32 tokens per session scan A 6738e287f7db

Subscribe to this mod's changes

nw-query-optimization is a skill published in the GitHub repository nWave-ai/nWave (636 stars, last pushed 11d ago), licensed MIT. It adds 32 tokens to every session and 1,278 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-09-03.

Related

nw-query-optimization compared with skills from other repositories

nw-query-optimization next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
nw-query-optimizationnWave-ai/nWaveSkill63611d agoMITA32Claude Code
test-database-seedingmakifbaysal/tasktrooperSkill123todayApache-2.0A37Claude Code, Codex
flux-recontonone-ai/tononeSkill842d agoMITA48Claude Code
V3 Memory Unificationruvnet/rufloSkill83ktodayMITA51Claude Code
tdd-workflowDVNghiem/FlowDeckSkill4415d agoMITA39Claude Code, Codex
matt-tdddeepklarity/harness-kitSkill10820d agoMITA51Claude Code
api-baas-neonagents-inc/skillsSkill281mo agoMITA20Claude Code, Codex