query-optimization

query-optimization is a skill for Cursor from girijashankarj/cursor-handbook. It costs 28 tokens per session (334 once invoked), scanned A, original, MIT.

A workflow for finding and improving slow database queries. It compares how a query runs before and after changes using the database's execution plan and measured timings.

In plain words
What is it for?
Use it to inspect query plans, add or adjust indexes, rewrite queries, benchmark improvements, update application code, and add related tests and monitoring.
Why use it?
It helps identify causes such as missing indexes, unnecessary joins, or inefficient pagination instead of relying on guesses. It also checks that faster queries still return the same results.

Skill for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it to inspect query plans, add or adjust indexes, rewrite queries, benchmark improvements, update application code, and add related tests and monitoring.

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

Made for: Cursor.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/girijashankarj/cursor-handbook/query-optimization.svg)](https://agentmods.dev/skills/girijashankarj/cursor-handbook/query-optimization)
Your own site
<a href="https://agentmods.dev/skills/girijashankarj/cursor-handbook/query-optimization"><img src="https://agentmods.dev/badge/skills/girijashankarj/cursor-handbook/query-optimization.svg" alt="Measured on agentmods" height="20"></a>
Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 334 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.00028 $0.00334
Opus 5 $0.00014 $0.00167
Sonnet 5 $0.00006 $0.00067
Haiku 4.5 $0.00003 $0.00033

Measured 3d ago against content hash 653b844863a0, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

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 3d 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.

.cursor/skills/database/query-optimization/SKILL.md · 48 lines

What it actually says

Skill: Optimize Database Query

Trigger

When a query is slow or user asks to optimize database performance.

Steps

Step 1: Identify Slow Query

  • Get the query text
  • Measure current execution time
  • Check query frequency (how often it runs)

Step 2: Analyze Query Plan

  • Run EXPLAIN ANALYZE on the query
  • Identify sequential scans on large tables
  • Check for missing indexes
  • Look for unnecessary joins or subqueries
  • Check sort operations (external sorts)

Step 3: Optimize

Common optimizations:

  • Add missing indexes
  • Rewrite subqueries as JOINs
  • Add WHERE clause filters to reduce data
  • Use cursor-based pagination instead of OFFSET
  • Add partial indexes for filtered queries
  • Denormalize if read performance is critical

Step 4: Benchmark

  • Run optimized query with EXPLAIN ANALYZE
  • Compare before/after execution times
  • Test with production-like data volume
  • Verify results are identical

Step 5: Implement

  • Update query in code
  • Create migration for new indexes
  • Add monitoring for the query
  • Update any affected tests

Completion

Query optimized with measurable improvement and monitoring in place.

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. 3d ago First seen · 48 lines · 28 tokens per session scan A 653b844863a0

Subscribe to this mod's changes

query-optimization is a skill published in the GitHub repository girijashankarj/cursor-handbook (30 stars, last pushed 7d ago), licensed MIT. It adds 28 tokens to every session and 334 once invoked, about $0.0001 per session on Opus 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

Other skills, from other repositories

backend-db-performance

Optimize slow queries, indexes, and N+1s. Use when "slow query", "database performance", "add an index", or "N+1". Schema consistency → audit-db-schema. RLS access control → plan-rls-audit.

kensaurus/cursor-kenji · 56 tokens

sql-optimization-patterns

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

wshobson/agents · 44 tokens

octocode-research

Use when code must be checked, not assumed: trace connections (callers, imports, cross-repo wiring, what breaks if I change it), locate behavior, map a system, diagnose a failure, RCA. Also for external repositories, npm packages, upstream/prior art, and general research. Plan a coding flow before writing, validate it…

bgauryy/octocode · 148 tokens

firebase-cloud-firestore

Use when setting up Firestore, designing schemas, doing CRUD, creating listeners, paginating queries, configuring indexes, enabling offline persistence, or writing security rules.

evanca/flutter-ai-rules · 37 tokens

firebase-database

Use when syncing real-time data, structuring JSON trees, reading/writing, creating listeners, enabling offline persistence, managing presence, sharding, or writing security rules.

evanca/flutter-ai-rules · 38 tokens

firebase-crashlytics

Use when implementing crash reporting, capturing fatal/non-fatal errors, recording isolate/async exceptions, customizing reports, or uploading obfuscated symbols.

evanca/flutter-ai-rules · 34 tokens