n-plus-one-detector

Detect and design out N+1 data-access patterns using query evidence.

2|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/nguyenpv1980-wq/Project-Aegis --skill n-plus-one-detector-nguyenpv1980-wq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n-plus-one-detector
Source: https://github.com/nguyenpv1980-wq/Project-Aegis/tree/main/.claude/skills/n-plus-one-detector
Command: npx skills add https://github.com/nguyenpv1980-wq/Project-Aegis --skill n-plus-one-detector-nguyenpv1980-wq

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps detect and eliminate chatty data-access patterns that make apps slow even when each individual query looks fast, especially the classic N+1 problem, repeated identical lookups, serial awaited calls in loops, and over-fetching.

Core Features & Use Cases

  • Evidence-first diagnosis: Uses query counts, logs, ORM instrumentation, and request traces to confirm the pattern before proposing changes.
  • Pattern-matched fixes: Recommends scoped eager loading, batched loaders, grouped aggregates, joins, denormalization, or batched calls depending on the access shape.
  • Regression protection: Designs query-count budget tests so the same performance defect cannot silently return.
  • Use case: A projects page issues one parent query and dozens of child lookups, or a GraphQL API fires one database request per field across a list of items.

Quick Start

Ask for an evidence-first diagnosis of the chatty query pattern in your endpoint, identify the injection site, and design the smallest fix with a query-count regression guard.

Frequently Asked Questions about n-plus-one-detector

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the N+1 query problem and how do chatty data-access patterns slow down my application?

The N+1 query problem occurs when an ORM-backed endpoint fires one parent query followed by dozens of individual child lookups. Each query looks fast in isolation, but total request latency scales linearly with the result-set size, creating severe performance bottlenecks.

How do I fix N+1 queries in my ORM-backed pages and list endpoints?

Fix N+1 queries by applying scoped eager loading, batched loaders, or grouped aggregates depending on the access shape. The Skill diagnoses the exact chatty pattern using query counts and request traces, then recommends the smallest targeted fix for your specific data-access loop.

How do I prevent N+1 query regressions from silently returning after a fix?

Prevent N+1 regressions by designing query-count budget tests that assert the maximum allowed database requests per endpoint. These regression guards monitor request-scoped query evidence, ensuring the same chatty data-access defect cannot silently return during future development.

Does this approach work for detecting chatty queries in GraphQL resolvers and serialized list responses?

Yes, chatty query detection applies directly to GraphQL APIs where resolvers fire one database request per field across a list of items. The Skill pattern-matches fixes like batched loaders and scoped eager loading specifically for resolver loops and serialized list endpoints.

What evidence do I need to diagnose a chatty query performance issue before applying a fix?

Diagnosing chatty query performance requires per-request query evidence such as query counts, ORM instrumentation logs, and request traces. This evidence-first approach confirms the exact data-access pattern before proposing scoped batching, eager loading, or denormalization changes.

When should I use request-scoped caching instead of eager loading to resolve repeated identical lookups?

Use request-scoped caching only when appropriate for repeated identical lookups within a single request lifecycle. For list endpoints where latency scales with result-set size, scoped eager loading or batched loaders are generally preferred over caching to eliminate serial awaited calls.