Use when user asks about N+1 queries, performance optimization, query optimization, reduce API calls, improve render performance, fix slow code, optimize database, or reduce bundle size. Provides guidance on identifying and fixing performance anti-patterns across database, backend, frontend, and API layers.
This skill is limited to using the following tools:
The N+1 problem occurs when code executes N additional queries to fetch related data for N items from an initial query.
Identification:
Fix Strategies:
Severity: HIGH - Scales linearly with data size, causes exponential slowdown
Retrieving more data than needed from API or database.
Identification:
Fix Strategies:
?fields=id,name parameterSeverity: MEDIUM - Increases bandwidth, memory, serialization time
Requiring multiple requests to get needed data.
Identification:
Fix Strategies:
/users?include=ordersSeverity: MEDIUM - Increases latency, connection overhead
Returning unbounded result sets.
Identification:
findAll() without paginationFix Strategies:
?page=1&limit=20?cursor=abc&limit=20 (better for large sets)Severity: HIGH - Can crash server/client with large data
O(n²) or worse complexity where better solutions exist.
Identification:
Fix Strategies:
Severity: HIGH - Becomes unusable with large data
Components re-rendering when their output hasn't changed.
Identification:
Fix Strategies:
Severity: MEDIUM-HIGH - Causes janky UI, especially on lists
Running async operations one-by-one when parallel is possible.
Identification:
Fix Strategies:
Severity: MEDIUM - Multiplies latency
| Issue | Detect | Fix |
|---|---|---|
| N+1 queries | Query in loop | Eager load / batch |
| Missing index | Slow WHERE/JOIN | Add index |
| SELECT * | No column list | Specify columns |
| No LIMIT | Unbounded query | Add pagination |
| Issue | Detect | Fix |
|---|---|---|
| O(n²) loop | Nested iteration | Use Set/Map |
| Sequential await | await in sequence | Promise.all |
| Sync I/O | fs.readFileSync | Use async version |
| No caching | Repeated computation | Memoize |
| Issue | Detect | Fix |
|---|---|---|
| Re-renders | Inline objects/functions | Memoize |
| Bundle size | Large imports | Tree-shake/split |
| Memory leak | No cleanup | useEffect cleanup |
| Layout thrash | Read+write DOM | Batch DOM ops |
| Issue | Detect | Fix |
|---|---|---|
| Over-fetching | All fields returned | Field selection |
| Under-fetching | Multiple requests | Include/expand |
| No pagination | Unbounded lists | Add limit/cursor |
| N+1 calls | Fetch in loop | Batch endpoint |