# ORM N+1 Query Bottleneck Exterminator

> Finds the lazy attribute access inside a loop that turns one request into hundreds of queries, and rewrites it as eager loading or a window function - without replacing it with a cartesian join.

ORM N+1 Query Bottleneck Exterminator is a subscription AI agent skill on Agensi by AllAccessData. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $5/mo (subscription, cancel anytime)
- Creator: [AllAccessData](https://www.agensi.io/creators/allaccessdata)
- Version: 1.1
- Last updated: 2026-11-28
- Security: scan passed (2026-11-28); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/orm-n-1-query-bottleneck-exterminator
- Tags: data-databases, code-quality-review, apis-backend

## About this skill

**ORM N+1 Query Bottleneck Exterminator** One query, then one more per row. The page is fine with ten records and unusable with a thousand.

Built for backend developers working through an ORM. Runs on Claude, Codex, Hermes, Gemini, and GPT-4 and any framework that loads a SKILL.md.

What's included:
* **Defined input contract:** your models and the query path, analysed with a local SQL parser.
* **Deterministic decision engine:** traces where a relationship attribute is touched inside an iteration - the line that triggers the extra query is usually innocuous-looking and nowhere near the query that fetched the collection. It reports the query count as a function of row count, which is what makes the problem legible.
* **The right fix per case:** a join-based eager load where the relation is single-valued, a separate prefetch where it is a collection, or a window function where an aggregate per row is what is actually wanted.
* **The counter-check:** eager loading everything is its own failure. Joining several one-to-many relations in one query multiplies rows, and the result is slower than the N+1 it replaced - so the prescription says which relations to load together and which to fetch separately.
* **Audit-ready deliverable:** the offending access sites, the rewritten query, and the before-and-after query count.

Runs on local parsing and an in-memory database for validation; credentials come from environment variables and are never printed.

_Confirm against query logs with production-like data volumes. An ORM's generated SQL varies by version and dialect, and the only honest measure of the fix is the query count and latency it actually produces._

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the ORM N+1 Query Bottleneck Exterminator skill from Agensi" and describe your task.
3. Subscribe on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What does ORM N+1 Query Bottleneck Exterminator do?

Finds the lazy attribute access inside a loop that turns one request into hundreds of queries, and rewrites it as eager loading or a window function - without replacing it with a cartesian join.

### Which AI agents support ORM N+1 Query Bottleneck Exterminator?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use ORM N+1 Query Bottleneck Exterminator?

Connect your AI agent to Agensi through MCP, then ask it to use ORM N+1 Query Bottleneck Exterminator on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
