performance-optimization

Detect and fix Rails runtime performance issues like N+1 queries and slow SQL.

1|Updated Jan 8, 2026
One-click install
npx skills add https://github.com/LaunchPadLab/ai-bank --skill performance-optimization-launchpadlab
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: performance-optimization
Source: https://github.com/LaunchPadLab/ai-bank/tree/main/claude/skills/performance-optimization
Command: npx skills add https://github.com/LaunchPadLab/ai-bank --skill performance-optimization-launchpadlab

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you identify and eliminate common Rails runtime performance problems like N+1 queries, slow SQL, missing indexes, memory growth, and inefficient response paths.

Core Features & Use Cases

  • N+1 detection and prevention (Bullet + eager loading): Use Bullet to detect N+1 behavior and apply includes/preload/eager_load patterns to reduce query counts.
  • Query and database optimization: Optimize slow queries using EXPLAIN, targeted indexing (including composite/partial/covering indexes), and better ActiveRecord patterns (select/pluck, exists?).
  • Memory and throughput improvements: Reduce memory bloat with batching (find_each/in_batches), streaming-friendly querying (pluck/enumerators), and safer update strategies (update_all).
  • Profiling and test validation: Use rack-mini-profiler for request profiling and add query-count assertions in tests to prevent regressions.

Quick Start

Ask the AI to review your Rails endpoint for N+1 queries and return the exact eager-loading changes needed to reduce the query count, then verify the result with a Bullet-based test configuration.

Frequently Asked Questions about performance-optimization

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

FAQPage Schema
How do I fix N+1 queries in Rails?

Fix N+1 queries in Rails by configuring Bullet to detect lazy loading and applying ActiveRecord eager loading patterns like includes, preload, or eager_load to batch associated records and reduce query counts.

What's the best way to optimize slow SQL queries in ActiveRecord?

Optimize slow SQL queries by analyzing EXPLAIN plans, adding targeted database indexes like composite or covering indexes, and refactoring ActiveRecord patterns to use select, pluck, or exists? for faster data retrieval.

How does rack-mini-profiler help with Rails performance?

Rack-mini-profiler helps with Rails performance by measuring request-level execution times and database query costs, allowing you to pinpoint slow endpoints and identify which ActiveRecord calls require optimization.

How do I prevent Rails performance regressions in tests?

Prevent Rails performance regressions by adding test-time query counting assertions and Bullet configuration to your test suite, ensuring that N+1 queries or unexpected database calls fail the build before deployment.

Can I reduce memory bloat when processing large ActiveRecord datasets?

Reduce memory bloat when processing large ActiveRecord datasets by replacing load-all queries with batching methods like find_each or in_batches, and using pluck or enumerators to stream records without instantiating full objects.

Does Bullet work with Rails test environments for N+1 detection?

Bullet works with Rails test environments for N+1 detection by raising warnings or errors when associations are lazily loaded or eagerly loaded unnecessarily, validating eager loading strategies during automated test runs.