n-plus-one-prevention
Installation
SKILL.md
N+1 Query Prevention
Overview
Never query in a loop. Fetch related data in a single query.
N+1 is when you fetch N items, then make N more queries to get related data. It's the most common database performance killer.
When to Use
- Fetching a list with related data
- Loop that contains a database query
- Slow list/index endpoints
- Multiple queries for one API response