What problem does it solve?
This Skill solves the pervasive Rails performance issue of undetected N+1 queries, which AI coding agents frequently introduce when generating controller and view code, leading to excessive database load and slow endpoint response times.
Core Features & Use Cases
- N+1 Detection: Uses Bullet for association-aware detection in development and test, and Prosopite to catch raw query pattern N+1s that Bullet misses.
- Optimization Patterns: Provides step-by-step fixes including eager loading with
includes/preload/eager_load, counter cache implementation for count N+1s, and denormalization guidance for complex query scenarios.
- Production Diagnosis: Includes workflows for identifying production-only N+1s via query log tags, APM tools, and
pg_stat_statements, plus an EXPLAIN ANALYZE reference for deep SQL analysis.
- Use Case: For a slow
/posts index that loads post authors and comment counts per row, the skill identifies both N+1s, adds the correct eager loading, recommends a counter cache for comment counts, and wires up Bullet to catch future regressions in test suites.
Quick Start
Use the n-plus-one-killer skill to diagnose and fix the slow /posts endpoint that loads post authors and comment counts per row.