- Home
- Skills
- Data & Databases
- DB Query Optimizer
Works with the AI Agents you already use
DB Query Optimizer
Detects and fixes N+1 queries, missing indexes, and ORM performance bottlenecks in SQL, Prisma, Django, and more.
$5
DB Query Optimizer
Example session with this skill installed
Why is this Prisma call slow? It fetches all posts, and then for each post, my UI displays the author name and the count of comments. It works fine locally but hangs in production.
- Read your context and instructions
- Compiled the db query optimizer
This is a classic N+1 query. You are fetching N posts, then triggering 2 additional queries per post for the author and comments. In production with 100 posts, this is 201 queries.
Fix: Update your Prisma findMany to include:
include: { author: true, _count: { select: { comments: true } } }
Connects securely to your tools. The creator never sees your data.
About this skill
The problem
Database performance issues often stay hidden during development because ORM code looks clean despite executing inefficiently. N+1 queries and missing indexes only reveal themselves as catastrophic slowdowns or connection pool exhaustion once your data volume grows in production.
What it does
- Identifies N+1 query patterns in ORM code and provides the exact eager-loading or batching syntax for your specific framework.
- Analyzes
EXPLAINandEXPLAIN ANALYZEoutput to detect sequential scans and inefficient query plans. - Flags missing indexes on foreign keys,
WHEREclauses, andORDER BYstatements, accounting for composite index column order. - Detects application-level filtering and pagination bugs that should be handled at the database layer.
- Diagnoses connection pool exhaustion caused by high query volume per request.
Frameworks & tools
Supports Prisma, Sequelize, TypeORM, Django ORM, ActiveRecord, SQLAlchemy, and Eloquent. Works with PostgreSQL, MySQL, and SQLite.
Why this beats prompting it yourself
General LLMs often suggest generic fixes or hallucinate ORM methods that do not exist. This skill uses framework-specific reference patterns to ensure the suggested fix is syntactically correct and actually addresses the underlying execution plan rather than just making the code look better.
Use cases
- Auditing an API endpoint that has become progressively slower as the database grows.
- Refactoring legacy ORM code to eliminate N+1 queries in serializers and view layers.
- Optimizing database performance by analyzing slow query logs and execution plans.
- Troubleshooting intermittent database timeouts and connection pool errors under load.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.
Cannot accurately predict performance gains without schema and row count data. Requires manual verification of index existence if schema is not provided.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
3 uses
Times used to date
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 months ago